You are here

Batch File Shortcut To USB With Different Drive Letters

5 posts / 0 new
Last post
SpeedyGuitarMan
Offline
Last seen: 14 years 3 months ago
Joined: 2008-03-22 03:47
Batch File Shortcut To USB With Different Drive Letters

Hey guys

Im working on creating a batch file to open my USB drive whenever i run it.
I dont want it to run AUTOMATICALLY as soon as i stick my usb in though.

I was thinking along the lines of the name of the USB.
So if i had named my USB "SpeedyUSB" it can open it.

I have some code so far that will open a certain drive letter if that drive letter is in use, this is my code:

%SystemRoot%\explorer.exe "E:\"

This opens E:\ in explorer (not Internet Explorer, just a normal window like My Music etc)

Now how do i do the same thing using my USB drive's name so that no matter what USB drive letter it has, it will always open?

Any help much appreciated,
Speedy

ozbodd
Offline
Last seen: 13 years 10 months ago
Joined: 2007-02-22 15:12
You could easily test the most common

if exist d:\PortableApps\ %SystemRoot%\explorer.exe "D:\"
if exist e:\PortableApps\ %SystemRoot%\explorer.exe "E:\"
if exist f:\PortableApps\ %SystemRoot%\explorer.exe "F:\"
if exist g:\PortableApps\ %SystemRoot%\explorer.exe "G:\"

lol very crude but I am not a batch coder ...

Zach Thibeau
Zach Thibeau's picture
Offline
Last seen: 8 years 10 months ago
Developer
Joined: 2006-05-26 12:08
Even with your proposed

Even with your proposed method you still need the help of Autorun.inf other wise what your proposing will not work

your friendly neighbourhood moderator Zach Thibeau

SpeedyGuitarMan
Offline
Last seen: 14 years 3 months ago
Joined: 2008-03-22 03:47
can anyone point me to a site

thanks for the suggestion.
ill be tring that tomorrow thanks!
can anyone point me to a site where fairly experienced batch coders may go?
no offense but i just want to ask a professional as well.

dark_yux
Offline
Last seen: 8 years 7 months ago
Joined: 2007-10-23 11:23
Use this varible....
%drive%/portableapps/something.bat

Here's where I go:

http://www.computerhope.com/batch.htm#02
http://www.easydos.com/dosindex.html

self.path = path if self.path == None else self.path

Log in or register to post comments