USB Applications › Batch files


The programs of a portable kit cannot be started by shortcut icons, since Windows shortcut icons support only absolute paths, i.e., full paths starting with a drive letter (C:\Program Files\KeePass\KeePass.exe), and not relative paths, i.e., paths that work relative to the directory from which a command is issued. A portable USB kit needs relative paths, since the keydrive letter will vary depending on the system. The system will give to the keydrive the first available drive letter. This can be anything from d: to z:

The most basic way to start a program is to look for its executable and double-click on it. E.g., to start KeePass, look for KeePass.exe and double-click on it. If you use more than a couple of programs, this is not convenient. The most convenient solution is a launcher for USB apps, or, for keyboard lovers, AutoHotkey. Another basic and simple solution is batch files. Batch files work in any Windows computer, with no need for additional programs.

How

Let’s say you have a folder in the keydrive for your USB programs: “Apps”, and that all your portable apps are in child folders of this folder.

Spaces in paths

In general, it is good to avoid spaces in paths. If the path contains spaces, e.g. ..\Easy Cleaner\easyclea.exe, enclose it in double quotes: "..\Easy Cleaner\easyclea.exe", or Windows will think the path ends at the first blank space, and will interpret the rest as a nonsensical command.

Dots, double dots & backslashes

Another way

If you usually work with the same set of programs, you can make just one batch file to start them all at once:

@echo off
start apps\freecommander\freecommander.exe
start apps\portablefirefox\portablefirefox.exe
start apps\skype\skype.exe /datapath:apps\skype\skypedata /removable
start apps\win32pad\win32pad.exe
            

Give it a name, say “Programs.bat” and save it in the root directory of the keydrive. Double-click on it to start your programs. This example also illustrates the concept of the batch file: a file by which a batch of commands is executed at once.