所以我想创建一个批处理文件,将根据另一个程序的输出做不同的事情。基本上,第一个程序输出一些关于硬盘驱动器加密状态的信息。下面是当一个驱动器未加密在Windows批处理文件FOR/F循环故障
S:\>beinvvol.exe xlc
------------------------------------------------------------------------
BEInvVol, Utimaco Safeware AG - A member of the Sophos Group
Decommissioning Tool for fully SGN-encrypted Volumes
------------------------------------------------------------------------
&Info: SGN filter driver off
&Info: Target log-file "S:\BEInvVol.log"
------------------------------------------------------------------------
Listing info for the target volume(s) -command xlc
Date: 2011-07-26 13:31:01
[Volume C:]
Drive Type: DRIVE_FIXED
[Boot Sector]
Media Type: Plain -not SGN
Media Label:
Media Serial Number: {8C19-DCCD}
File System: NTFS
Size: 232.88 GB
这里输出时的驱动器加密
S:\>beinvvol.exe xle
------------------------------------------------------------------------
BEInvVol, Utimaco Safeware AG - A member of the Sophos Group
Decommissioning Tool for fully SGN-encrypted Volumes
------------------------------------------------------------------------
&Info: SGN filter driver off
&Info: Target log-file "S:\KeyDestroy\BEInvVol.log"
------------------------------------------------------------------------
Listing info for the target volume(s) -command xle
Date: 2011-07-26 12:41:48
[Volume E:]
Drive Type: DRIVE_FIXED
[Boot Sector]
Media Type: SGN -fully encrypted
SGN Media GUID: {83490018-50C3-B4E3-829E-ACE3B23C86D3}
File System: NTFS
Size: 298.09 GB
[KSA Original]
Sector Offset ..... 0x0000000000065ED8 (417496)
Byte Offset ....... 0x000000000CBDB000 (213757952)
Size in Sectors ... 0x15 (21)
Size in Bytes ..... 0x2A00 (10752)
[KSA Backup]
Sector Offset ..... 0x000000002542D660 (625137248)
Byte Offset ....... 0x0000004A85ACC000 (320070270976)
Size in Sectors ... 0x15 (21)
Size in Bytes ..... 0x2A00 (10752)
的“XLC”和“XLE”的论点是什么,你得到的选择驱动器。所以,我看到在未加密驱动器中,对于“介质类型”,我有“Plain -not SGN”,对于加密驱动程序,我有“SGN -fully encrypted”
现在,我试图编写一个FOR/F循环,当它看到“Plain -not SGN”时,它会转到文件的另一部分。这里是我的批处理脚本至今:
@ECHO OFF
::Determine if drive is encrypted
FOR /F "tokens=3,4,5 delims= " %%A IN ('S:\beinvvol.exe xlc') DO IF /I "%%A%%B%%C"=="Plain-notSGN" GOTO NOTENCRYPTED
:ENCRYPTED
ECHO Yes
GOTO END
:NOTENCRYPTED
ECHO No
:END
现在,我的思维过程是,从第三个,第四和第五代币列表中(对于我感兴趣的行,第一个令牌将被“媒体“,第二个是”类型“,第三,第四和第五个将是”普通“,”不“和”SGN“或”SGN“”完全“”加密“),字符串将等于“Plain-notSGN”(只是连接所有这些字符串)。但是,这不起作用。有什么建议么?
这是聪明的。从未见过&&和||之前一起使用。我想我会更改一些批处理脚本= D – Mechaflash
谢谢,我喜欢这个版本!也感谢您的解释;我刚开始使用批处理文件,以及不明确的运算符(如> >> &&& |) ||很容易混淆。 – romellem