HOW TO: Refer to programs on the same drive as portable Opus

USB drive letters

People who run Opus from a USB drive often carry other programs on the same drive and want to run them from Opus buttons.

The USB drive won't always be assigned the same letter, so how do you create buttons which refer to other programs on the USB drive when you don't know what the path will be?

The home alias

You can do it using the home alias. This built-in alias always points to where Opus is installed (where you will find dopuslib.dll and so on).

To see where the home alias points, type /home into the location field in Opus.

Let's look at how you can use the home alias in your buttons...

  • Relative to home:
    If your USB drive has Opus installed in X:\DOPUS\ and you want to run X:\UTILS\HANDY.EXE then put this in your button:

    {alias|home}..\UTILS\HANDY.EXE
    

    As is standard on Windows, adding .. after a folder will take you to its parent. So in this example, {alias|home}..\ is the same as X:\ but without having the drive letter hard-coded.

  • Via the drive letter:

    You can also use the {alias} code to get just the drive letter that Opus is running from. In this particular example the parent of the home folder is the same as the root of the drive so it doesn't make much difference. Here is the button code anyway:

    {alias|home|\}UTILS\HANDY.EXE
    
  • Alternative:

    If you are not creating an MS-DOS Batch type of button then Opus will automatically expand /home without you having to use the {alias} code:

    /home\..\UTILS\HANDY.EXE
    

    Just remember that it doesn't work with MS-DOS Batch buttons. It's probably best to get into the habit of always using one of the other methods since they work in all situations.

Not just for USB installs

All of this works when Opus is installed normally as well. If you have Opus and Windows installed to the default locations then all of the follow examples will launch the windows Calculator:

{alias|home|\}Windows\system32\calc.exe
alias|home}..\..\..\..\Windows\system32\calc.exe
/home\..\..\..\..\Windows\system32\calc.exe

Of course, it would be much easier to run C:\Windows\system32\calc.exe directly if you know that's where it will always be.

Don't forget the quotes

If there are spaces in your paths then don't forget to put quotes around them. For example:

"{alias|home|\}Program Files\Beyond Compare 3\BComp.exe"

Referring to a USB drive by label when Opus isn't running from it

If Opus isn't running from the USB drive you want to refer to then you can use my Launch via Label script to look up the label and run any command you want.

That script can be useful if you have Opus installed on your harddrive but also have a portable USB drive which you want to run commands on (and which you may also have Opus installed for use on other computers). You can create buttons in Opus which run the script and always act on the USB drive regardless of the letter is assigned to it.

If you combine the /home alias with the LaunchViaLabel script then you can create a single configuration for both your harddrive and portable Opus installs which does things using your USB drive.

Using the same drive-letter for a device every time you insert it

The USBDLM tool can be used on a computer to reserve a drive-letter for a particular USB device. (This won't affect what happens when the device is plugged into other computers, but can ensure a consistent drive-letter for backup devices etc. when you plug them into your main computer.)

1 Like