返回列表 发帖
回复 2# 小白龙


test-1.bat
@echo off
for /f "delims=" %%i in ('wmic Partition where "BootPartition='true'" get type /value ^| find "="') do (
    echo,%%i | find "GPT" >nul
    if errorlevel 1 (
        echo MBR
    ) else (
        echo GPT
    )
)
pauseCOPY
1

评分人数

我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 4# 小白龙
wmic Partition get * /valueCOPY
观察一下这个命令的结果,看看用哪个条件比较合适,然后修改 where 后面的条件。

如果需要模糊匹配,请参考这个 like 语法:
http://bbs.bathome.net/thread-67172-1-1.html#pid273113
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 4# 小白龙


test-1.bat
@echo off
REM 设置待查看的盘符
set "MyLetter=C:"
for /f "tokens=1-2 delims==" %%a in ('wmic LogicalDisk where "DeviceID='%MyLetter%'" assoc:value /resultclass:Win32_DiskPartition ^| findstr /b /c:"DiskIndex=" /c:"Index="') do (
    for /f "delims=" %%i in ("%%b") do (
        if "%%a" equ "DiskIndex" (
            set "LD2DI=%%i"
        ) else if "%%a" equ "Index" (
            set "LD2I=%%i"
        )
    )
)
for /f "delims=" %%i in ('wmic Partition where "DiskIndex='%LD2DI%' and Index='%LD2I%'" get type /value ^| find "="') do (
    echo,%%i | find "GPT" >nul
    if errorlevel 1 (
        echo MBR
    ) else (
        echo GPT
    )
)
pauseCOPY
test-2.bat
@echo off
REM 设置待查看的盘符
set "MyLetter=C:"
for /f "delims=" %%i in ('wmic LogicalDisk where "DeviceID='%MyLetter%'" assoc:value /resultclass:Win32_DiskPartition ^| findstr /b "Type="') do (
    echo,%%i | find "GPT" >nul
    if errorlevel 1 (
        echo MBR
    ) else (
        echo GPT
    )
)
pauseCOPY
1

评分人数

我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

返回列表