Page 1 of 1

USB Drive

Posted: 23 Oct 2014 13:40
by Jamessotech
I am trying to write batch file that will recognize a thumb drive and assign drive letter automatically.
For installing a program from the drive. I have tried a couple from the internet but they do not recognize my thumb drive.

This is one I tried:

Code: Select all

set "USBDRV="
for %%a in (d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist "%%a:\$Emergency Plan 2014\" set USBDRV=%%a
)
if not defined USBDRV echo THE USB DRIVE WASN'T FOUND & pause&goto :EOF
echo copying Emergency Plan 2014 to Desktop
RD /s /q "%USBDRV%:\$Emergency Plan 2014"
xcopy   "%USBDRV%:\JCSO Emergency Plan 2014 v. 200.exe\" to "C:\Emergency Plan 2014\" /s /c
pause


It seems to be looking for the thumb drive but it stops searching at "H" and the drive assigned by computer is "J",
any help will be appreciated.
:?:

MOD EDIT: Added Code Tags.

Re: USB Drive

Posted: 23 Oct 2014 14:02
by Squashman
Are you running the batch file from the USB drive?

Re: USB Drive

Posted: 23 Oct 2014 14:36
by foxidrive

Code: Select all

set "USBDRV="
for %%a in (d e f g h i j k l m n o p q r s t u v w x y z) do (
echo searching on drive %%a:
if exist "%%a:\$Emergency Plan 2014\" set USBDRV=%%a
)
if not defined USBDRV echo THE USB DRIVE WASN'T FOUND & pause&goto :EOF
echo copying Emergency Plan 2014 to Desktop
RD /s /q "%USBDRV%:\$Emergency Plan 2014"
xcopy   "%USBDRV%:\JCSO Emergency Plan 2014 v. 200.exe\" to "C:\Emergency Plan 2014\" /s /c
pause


It seems to be looking for the thumb drive but it stops searching at "H" and the drive assigned by computer is "J",
any help will be appreciated.
:?:


Try the above - and make sure that \$Emergency Plan 2014\ is not located on drive H: