我需要一些关于指定安装的可移动磁盘路径的说明。我的批次代码......
wmic LOGICALDISK where driveType=2 get deviceID > "C:\Windows\Temp\wmic.txt"
cls
for /f "skip=1" %%b IN ('type C:\Windows\Temp\wmic.txt') DO (xcopy JKDClean.bat %%b /Y)
for /f "skip=1" %%b IN ('type C:\Windows\Temp\wmic.txt') DO (xcopy run.vbs %%b /Y)
echo -----
echo Cleaning removable disk
for /f "skip=1" %%b IN ('type C:\Windows\Temp\wmic.txt') DO (wscript %%b\run.vbs)
TIMEOUT /T 10 /NOBREAK
echo DONE!!!
echo -----
for /f "skip=1" %%b IN ('type C:\Windows\Temp\wmic.txt') DO (del /s /q /f %%b\*.inf)
Del C:\Windows\Temp\wmic.txt
echo -----
echo DONE!!!
pause
在第4行“xcopy JKDClean.bat %% b”路径运行得更好。 但我无法运行该vbs文件,“wscript %% b \ run.vbs”。我需要在可移动驱动器上运行vbs文件。如何指定当前可移动磁盘的路径???
答案 0 :(得分:1)
为什么这么多for循环:
@Echo Off
For /F "Skip=1" %%I In ('WMIC LogicalDisk Where DriveType^=2 Get DeviceID'
) Do (For %%J In (%%I) Do (Echo=Copy file.ext %%I & Echo=Copy file2.ext %%I
Echo=run %%I\file2.ext & Echo=Del/S/Q %%I\*.ext2))
Echo( Done & Timeout -1
注意您确实意识到内部使用的某些驱动器可以看作是可移动的,您的代码不仅仅适用于USB Thumb / Flash驱动器!