首页 > 解决方案 > manage-bde protectionaserrorlevel 不起作用

问题描述

嘿嘿,我正在编写一个批处理文件来定期检查是否启用了 bitlocker。但是,我意识到,在我可以使用任何多汁的自动化部分之前,我只是通过运行 manage-bde -status c: -p (作为管理员)得到一个错误。有人可以提供一个正确使用 manage-bde -status c: -p 的例子吗?我正在使用 64 位 Windows 10 机器。这是我的脚本和输出。谢谢!

@ECHO OFF
manage-bde -status c: -p
ECHO %ERRORLEVEL%
PAUSE
EXIT

结果是我在运行 manage-bde -status c: 时通常会得到的结果,并添加了一条错误消息:

Volume C: [Windows]
[OS Volume]

    Size:                 471.56 GB
    BitLocker Version:    None
    Conversion Status:    Fully Decrypted
    Percentage Encrypted: 0.0%
    Encryption Method:    None
    Protection Status:    Protection Off
    Lock Status:          Unlocked
    Identification Field: None
    Key Protectors:       None Found

ERROR: While performing the operation, a component unexpectedly returned FALSE.
-1
Press any key to continue . . .

标签: batch-filebitlocker

解决方案


以下示例使用了 manage-bde 命令的替代方法,您可能会发现该方法很有用。

该变量%ProtectionStatus%应包含01或的值2
以后的行6应该输出消息来解释这些整数的含义。
您可以随时根据您的要求更改该部分。

@Echo Off & SetLocal EnableExtensions
Set "ProtectionStatus=" & For /F Tokens^=* %%G In ('WMIC.exe
 /NameSpace:\\ROOT\CIMV2\Security\MicrosoftVolumeEncryption Path
 Win32_EncryptableVolume Where "DriveLetter='%SystemDrive%'" Call
 GetProtectionStatus 2^>NUL ^| find.exe "ProtectionStatus "')Do Set /A %%G 2>NUL
If Defined ProtectionStatus (If %ProtectionStatus% Equ 0 (Echo The volume is^
 not encrypted, partially encrypted, or the encryption key for the volume is^
 available in the clear on the hard disk.)Else If %ProtectionStatus% Equ 1 (
Echo The volume is fully encrypted and the encryption key for the volume is not^
 available in the clear on the hard disk.)Else Echo The volume is either^
 locked, or its protection status cannot be determined.)Else Echo An unknown^
 error occurred.
Pause

请注意,这也需要“以管理员身份运行”


推荐阅读