Reputation: 11
I looked at the possible solutions for my question, but am afraid my knowledge level doesn't permit me to ask the question correctly.
My USB drive is named CRUISER, and I have a couple apps that I wish to run, via a batch file on the host computer. Since I have no idea what the drive letter will be how can I resolve the drive by name in a batch file?
Here is what I have in my current host side batch file. (as you can see by the REM and pause statements, I've been testing....)
REM Start Portable Apps and Signup Shield Suite
cd C:\Documents and Settings\%USERNAME%\Local Settings\Application Data\Temp\SignupShield\
del signupshieldportable.exe
REM dir
REM pause
cd \
%CRUISER%
REM dir
REM pause
start StartPortableApps.exe
cd PortableApps
REM dir
REM pause
start SignupShieldPortable.exe
rem pause
All I want to do, is plug in the drive on my host, run the host based batch file, and have it find my CRUISER drive, regardless of the assigned drive letter, and run the two apps. I know I can put the batch file on the USB drive and run it from there as I have done this. Now it is just a challenge I need to resolve!
Thanks for the help
Upvotes: 1
Views: 1597
Reputation: 41267
Place cruiser.txt
in the root of the usb drive and use this code:
@echo off
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:\cruiser.txt" set "drv=%%a:"
Upvotes: 1
Reputation: 137
You can try naming the batchfile on the USB something unique, unlikely to exist on any other drive, eg: foobarsaysblah.bat
The above batch can then start the two apps you want.
Then on your host bat file, you just add lines for most drive letters and output errors to nul, eg:
d:\foobarsaysblah.bat 2>nul
e:\foobarsaysblah.bat 2>nul
f:\foobarsaysblah.bat 2>nul
g:\foobarsaysblah.bat 2>nul
h:\foobarsaysblah.bat 2>nul
i:\foobarsaysblah.bat 2>nul
Not very elegant, but gets the job done...
Upvotes: 0