@echo off
for /f "tokens=2 delims==" %%a in ('wmic logicaldisk where deviceid^='c:' get volumename /value') do (
if not "%%a"==" " (
echo %%a
)
)
PAUSE
后可以输出卷标,但是只显示后半部分, 比如c盘卷标是ssd1,输出的卷标是 d1
就像这样
R:\>for /F "tokens=2 delims==" %a in ('wmic logicaldisk where deviceid='c:' get volumename /value') do (if not "%a" == " " (echo %a ) )