以变量
获取驱动器LogicalDisk = "c:\d:\"
现在我希望驱动器以分号分隔;
喜欢LogicalDisk = "c:\;d:\;e:\;f:\"
@echo on
setlocal enabledelayedexpansion
for /f "tokens=2 delims==" %%d in ('wmic logicaldisk where "drivetype=3" get name /format:value') do (
set "LogicalDisk=!LogicalDisk!%%d\"
)
echo %LogicalDisk%
endlocal
pause
答案 0 :(得分:0)
或者
for /f "tokens=2 delims==" %%d in ('wmic logicaldisk where "drivetype=3" get name /format:value') do (
set "LogicalDisk=!LogicalDisk!%%d\;"
)
set"LogicalDisk=%LogicalDisk:~0,-1%"
echo %LogicalDisk%
或
for /f "tokens=2 delims==" %%d in ('wmic logicaldisk where "drivetype=3" get name /format:value') do (
set "LogicalDisk=!LogicalDisk!%%d\"
)
set"LogicalDisk=%LogicalDisk:\=\;%"
set"LogicalDisk=%LogicalDisk:~0,-1%"
echo %LogicalDisk%