Launch via Label (for portable USB users)

Various utilities related to Opus.

Launch via Label (for portable USB users)

Postby leo » 14 Aug 2009, 00:13

See Also: (FAQ) Refer to programs on the same drive as portable Opus

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:
    Code: Select all
    LaunchViaLabel.vbs "My USB Stick" __DRIVE__\HelloWorld.exe

    Will run this:
    Code: Select all
    U:\HelloWorld.exe

  • Example 2)

    If "LEOCAMERA" is mounted as M: then this:
    Code: Select all
    LaunchViaLabel.vbs "LEOCAMERA" Explorer.exe __DRIVE__

    Will run this:
    Code: Select all
    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.
User avatar
leo
Admin
 
Posts: 14449
Joined: 07 Nov 2004, 01:30
Location: London, UK
OS: Windows 7 64-bit
Opus: Illuminati

Postby GoinPostal » 16 Aug 2009, 23:35

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 "§"
Code: Select all
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
Code: Select all
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.)
Attachments
LaunchViaLabelV3.zip
(1.91 KB) Downloaded 123 times
User avatar
GoinPostal
 
Posts: 113
Joined: 02 Aug 2009, 02:31
Location: France
OS: Windows XP 32-bit
Opus: Directory Opus 9.x


Return to Tools