简体   繁体   中英

call a vbs file in a removable drive to run

I need a little explanation on specifying path to mounted removable disk. My batch code...

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

In line 4 "xcopy JKDClean.bat %%b" path is working better. But I couldn't run that vbs file, "wscript %%b\\run.vbs". I need that vbs file to be run eithin the removable drive. How specify path for current removable disk???

why so many for loops:

@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

Note you do realise that some drives used internally can be seen as Removable, your code isn't just catering for USB Thumb/Flash drives!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM