Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 使用EWFMGR获取写保护状态_Batch File_Cmd_Windows Embedded - Fatal编程技术网

Batch file 使用EWFMGR获取写保护状态

Batch file 使用EWFMGR获取写保护状态,batch-file,cmd,windows-embedded,Batch File,Cmd,Windows Embedded,我需要获取C:驱动器的写保护状态,如果当前已禁用,则启用写保护 我知道下面的命令可以给我CMD窗口上C:drive的状态 ewfmgr c: 但是如何将该值存储在变量中并检查写入保护当前是否已禁用 我需要以下(伪代码): 在PowerShell中,只需通过过滤器传递ewfmgr C:的输出: 在循环中批量使用: 在PowerShell中,只需通过过滤器传递ewfmgr C:的输出: 在循环中批量使用: 我试图使用它,但命令窗口很快出现和消失(我已经暂停了了),什么也没有发生。上面是PowerS

我需要获取C:驱动器的写保护状态,如果当前已禁用,则启用写保护

我知道下面的命令可以给我CMD窗口上C:drive的状态

ewfmgr c:
但是如何将该值存储在变量中并检查写入保护当前是否已禁用

我需要以下(伪代码):


在PowerShell中,只需通过过滤器传递
ewfmgr C:
的输出:

在循环中批量使用:


在PowerShell中,只需通过过滤器传递
ewfmgr C:
的输出:

在循环中批量使用:


我试图使用它,但命令窗口很快出现和消失(我已经暂停了
),什么也没有发生。上面是PowerShell,不是batch。如果你想要批处理,为什么要标记你的问题?哦,对不起,我是这方面的新手,实际上没有意识到区别。我尝试使用它,但命令窗口很快出现和消失(我已经有了
暂停
),什么也没有发生。上面是PowerShell,不是批处理。如果你想要批量生产,为什么要把你的问题贴上标签?哦,对不起,我是这方面的新手,实际上并没有意识到其中的区别。
currentStatus = Somehow get the status of C:
if currentStatus = disable
ewfmgr -enable
shutdown -r
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
)