使用 EWFMGR 获取写保护状态
Get Write Protection Status using EWFMGR
我需要使用 ewfmgr
获取 C: 驱动器的写保护状态,如果当前禁用,则启用写保护。
我明白以下命令可以让我在 CMD 上显示 C: 驱动器的状态 window
ewfmgr c:
但是如何将值存储在变量中并检查写保护当前是否被禁用?
我需要以下(伪代码):
currentStatus = Somehow get the status of C:
if currentStatus = disable
ewfmgr -enable
shutdown -r
在 PowerShell 中,只需将 ewfmgr C:
的输出传递给 Where-Object
过滤器即可:
ewfmgr c: | Where-Object {
$_.Trim() -match '^state\s+disabled$'
} | ForEach-Object {
ewfmgr c: -enable
shutdown -r
}
@echo off
for /f %%a in ('ewfmgr c: ^| findstr /i /r /c:"state *disabled"') do (
ewfmgr c: -enable
shutdown -r
)
我需要使用 ewfmgr
获取 C: 驱动器的写保护状态,如果当前禁用,则启用写保护。
我明白以下命令可以让我在 CMD 上显示 C: 驱动器的状态 window
ewfmgr c:
但是如何将值存储在变量中并检查写保护当前是否被禁用?
我需要以下(伪代码):
currentStatus = Somehow get the status of C:
if currentStatus = disable
ewfmgr -enable
shutdown -r
在 PowerShell 中,只需将 ewfmgr C:
的输出传递给 Where-Object
过滤器即可:
ewfmgr c: | Where-Object {
$_.Trim() -match '^state\s+disabled$'
} | ForEach-Object {
ewfmgr c: -enable
shutdown -r
}
@echo off
for /f %%a in ('ewfmgr c: ^| findstr /i /r /c:"state *disabled"') do (
ewfmgr c: -enable
shutdown -r
)