如何通过批处理脚本检测Windows中是否已安装EFI分区?

use*_*144 3 windows batch-file efi

我正在尝试编写批处理脚本来检测Windows中是否已安装EFI分区.

最终,我的目标是mountvol /S仅在尚未安装EFI分区时使用(安装EFI系统分区).

diskpart具有该list volume命令的实用程序mountvol本身具有一些可能有用的信息,但看起来这两个都需要一些字符串解析.

有没有更好的办法?

ies*_*sou 5

我不确定有没有更简单的方法......但是解析并不是那么大.这是应该做你需要的东西:

@echo off
setlocal enabledelayedexpansion
echo list volume > listvol.tmp

REM Checks for "efisys" in the list volume function. If it finds it, checks status. If not healthy sets var to No
for /F "tokens=6-9 delims= " %%G IN ('diskpart /s listvol.tmp') DO IF /I %%G==efisys set mounted=%%J

if '%mounted%'=='Healthy' set mounted=Yes
if not '%mounted%'=='Yes' set mounted=No

echo Is EFI drive mounted?
echo %mounted%.
pause

del listvol.tmp
endlocal
Run Code Online (Sandbox Code Playgroud)

编辑因为我正在解析错误的值.