Launch via Label (for portable USB users)

See Also: Refer to programs on the same drive as portable Opus
See Also: Same drive letter for USB devices each time


Directory Opus 10 and above:

Similar/better functionality is now built into Opus, so you probably won't need the script below.

From Opus 10.0.5.1 onwards, the folder alias system now supports accessing drives by their volume label, using /$<label> (e.g. /$Backup/ would refer to a drive labeled Backup).


Launch Via Label

LaunchViaLabel.vbs is a script you can use to run a command on a particular drive, looking up the drive via its label. It can be useful when you want to launch something from a USB drive which doesn't always have the same label.

You should run the script with at least two arguments. The first argument is the label of the drive you want to look up. The rest of the arguments are the command you want to run.

Any occurrences of DRIVE in the arguments will be replaced with the drive letter (e.g. "X:").

  • Example 1)

    If "My USB Stick" is mounted as U: then this:

    LaunchViaLabel.vbs "My USB Stick" __DRIVE__\HelloWorld.exe

    Will run this:

    U:\HelloWorld.exe

  • Example 2)

    If "LEOCAMERA" is mounted as M: then this:

    LaunchViaLabel.vbs "LEOCAMERA" Explorer.exe __DRIVE__

    Will run this:

    Explorer.exe M:

    That will launch Explorer showing the M: drive.

    (If you want to respect the default file manager instead of launching Explorer explicitly, you'd just launch the drive letter by itself and let Windows decide what to run. In that case you should set WaitForCommand=False at the top of the script. Otherwise you'll get an error message because the script can only wait for commands to complete if they run an executable directly.)

Get the script from my webpage, or a local copy here (may not always be up to date):

LaunchViaLabel100.zip (1.4 KB)

Here is V3 of the script.

Changes made gives the user the possibility of redirecting stream of the command line to a file & also pause the console at the end of command execution.

Example 3)
If there is the need to launch a command line with several parameters using redirection, you should replace the ">" character by "§"

LaunchViaLabel.vbs "My USB Stick" __DRIVE__\Command.exe -arg1 -arg2 §Redir.log

The Command.exe is launched using -arg1 & -arg2, and redirect the streams to Redir.log

Example 4)
If there is the need to visually check the output of the console, you can add "pause" argument

LaunchViaLabel.vbs "My USB Stick" __DRIVE__\Command.exe -arg1 -arg2 pause

The Command.exe is launched using -arg1 & -arg2, then paused at the end of the command execution.
(This can work together with redirection even if there's no real need to see the output in the console when redirecting streams to a file.)
LaunchViaLabelV3.zip (1.91 KB)