Absolute path woes
July 5, 2006 8:04 PM   Subscribe

Help me make my removable drive shortcuts not break when plugged into different computers!

I have a 5g iPod that I'm using part-time as a removable drive that I run a handful of portable apps off of. I put shortcuts in the top iPod directory ("Josh's iPod") to the different programs (which are in subdirectories within a directory on the iPod called "Portable Apps").

These shortcuts work fine as long as the iPod gets assigned to E:\, but whenever it gets assigned to a different drive letter (like F:\) they break. Is there something I can do to make my shortcut paths relative rather than absolute?

I'm thinking there's gotta be something like the %Userprofile% trick, maybe? Are there other relative paths other than that one? Google strips the %'s out of my searches!
posted by joshuaconner to Computers & Internet (8 answers total) 2 users marked this as a favorite
 
What OS?

With windows xp, I think it is impossible to make a shortcut with a relative path.

One thing you can do is make a batch file with a single command which runs the app.

So, to run portable firefox sitting on your removable storage, make a text file named firefox.bat with this single line...

"\public\Portable Apps\PortableFirefox\PortableFirefox.exe"

You could also make a simple html page with relative links to all of your stuff which would work no matter what OS you wield.
posted by utsutsu at 8:56 PM on July 5, 2006


Control Panel -> Administrative Tools -> Computer Management
Click on Disk Management
Right Click on the Drive and select 'Change Drive Letter and Paths'

Pick something near the bottom of the alpahbet (eg: Z). Whenever you plug the iPod in it will be assigned that drive letter. You can then use Z:\whatever for your shortcuts and you're relatively guaranteed to get the same drive letter everytime.
posted by blue_beetle at 9:00 PM on July 5, 2006


Oh, the html page thing will only really work for documents and such, not for apps.
posted by utsutsu at 9:04 PM on July 5, 2006


Best answer: Use PStart. Problem solved.
posted by caution live frogs at 9:15 PM on July 5, 2006


Response by poster: Thanks, all! Yes, I was running Windows XP.
posted by joshuaconner at 9:16 PM on July 5, 2006


Whenever you open something by double-clicking its icon, Windows sets the current drive and the current directory on that drive to match the folder containing the file you just opened.

If that file is a shortcut to an executable, Windows will reset the current drive and the current directory based on the contents of the "Start in:" field within the shortcut, then launch the executable that is the shortcut's target.

Unfortunately, there's no convenient way to create a shortcut whose target is a relative path; when you edit a shortcut, whatever you type into the Target: box is immediately resolved to an absolute drive:\pathname combination - %variables% and ..\..\.. prefixes and \absolute\paths\without\drive\letters all get evaluated immediately and the results substituted.

If you use batch files instead of shortcuts, though, you can do whatever you like.

For example: you could have a batch file called "Portable Firefox.bat" in the root directory of your iPod, containing this:

cd "\folder\containing\firefox\launcher"
start PortableFirefox.exe
exit

Note that the pathname on the cd command does not have a drive letter in front of it. The effect is to leave the current drive set to the the drive the .bat file itself is launched from, and change the current directory on that drive.

The start command will launch your application, which will see the current drive and current directory set to its own folder, then return control to the batch file as soon as the launch is done (instead of possibly waiting for the app concerned to complete).

Finally, the exit command closes down the batch file, so the only window left open is the one belonging to your launched application.

If you and your app don't care what the current drive and path are set to on launch, the batch file can be even simpler:

start "\folder\containing\firefox\launcher\PortableFirefox.exe"
exit

Note again that the pathname on that start command has no drive letter prepended: Windows will use the current drive, which is the one the batch file itself is on.

on preview: blue_beetle types faster than I do :-)
posted by flabdablet at 9:27 PM on July 5, 2006


The "change drive letter and paths" thing will need to be done on every computer you plug the iPod into, so it might not be terribly convenient.
posted by flabdablet at 9:28 PM on July 5, 2006


Response by poster: The "change drive letter and paths" thing will need to be done on every computer you plug the iPod into, so it might not be terribly convenient.

I just discovered this. Sticking with pstart for the moment, though using a .bat file is also a clever solution.
posted by joshuaconner at 5:30 PM on July 6, 2006


« Older Bellsouth DSL + Dell Wireless Configuration   |   How to find a certain kind of hip hop music? Newer »
This thread is closed to new comments.