Create A Batch File That Opens Applications You Choose From A List

Print View Mobile View

In a previous tip, I showed you how to create a batch file to open multiple applications at once.

That batch file works great if you want the same applications to always open at once.

But, what if you have a number of applications that you use frequently, and only want to choose from a list, a certain combination of applications to open at the same time?

For example, you have a book report due and you need to research the material on the Internet. In this case you want to open Microsoft Word and Firefox.

Or, it’s time to pay the bills, and you need to open Notepad, Calculator and Microsoft Excel.

To do this we can create a batch file with a list of applications. When you run the batch file, a menu will appear that will accept user input from the command line and open the applications that you choosen (as shown in above screen shot).

To create the batch file, first, you will want to make a list of applications that you use frequently.

For this example, here six applications are selected (remember they can be any amount and type of applications you want to use):

  • Notepad
  • Calculator
  • Microsoft Word
  • Microsoft Excel
  • Internet Explorer
  • Firefox

Next, find the executable path for each application. This can be accomplished by finding the shortcut of the application in the Start Menu and right click on the application icon (make sure the Shortcut tab is selected).

For Microsoft Office Applications, you will need to look in the folder where Office is installed. On my computer, the executable path is: C:\Program Files\Microsoft Office\Office12 EXCEL.EXE

NOTE: Your path may be different depending on the version of Windows and Office you are using.

For any application executable that you can not find, use Windows search (in XP and Vista) to help find the location.

Create The Batch File
Just right click on your desktop and select New -> Text Document. Next name the file what ever you want and for now, leave the extension as .txt (I have named my file chooseapp.txt).

Open the file that you created using notepad, then copy and paste the following code. An explanation of the code is listed below:

@echo off
cls
:start
echo.
echo 1. Notepad
echo 2. Calculator
echo 3. Microsoft Word
echo 4. Microsoft Excel
echo 5. Internet Explorer
echo 6. Firefox
echo 7. I’m Done
echo.
echo.
set /p x=Pick:
IF ‘%x%’ == ‘%x%’ GOTO Item_%x%

:Item_1
start /MIN /DC:\Windows\System32 notepad.exe
GOTO Start

:Item_2
start /MIN /DC:\Windows\System32 calc.exe
GOTO Start

:Item_3
start /MIN /D”C:\Program Files\Microsoft Office\Office10″ WINWORD.EXE
GOTO Start

:Item_4
start /MIN /D”C:\Program Files\Microsoft Office\Office10″ EXCEL.EXE
GOTO Start

:Item_5
start /MIN /D”C:\Program Files\Internet Explorer\iexplore.exe” http://www.google.com
GOTO Start

:Item_6
start /MIN /D”C:\Program Files\Mozilla Firefox” firefox.exe http://www.google.com
GOTO Start

:Item_7
exit

Here’s How The Batch File Works
The @echo off prevents displaying results of the commands at the prompt.
cls – clears the screen
:start – begins the commands to display the list
echo. – creates a blank line
echo 1. Notepad
echo 2. Calculator
echo 3. Microsoft Word
echo 4. Microsoft Excel
echo 5. Internet Explorer
echo 6. Firefox
echo 7. I’m Done

The above lines are the applications that will be displayed in the list. You should edited these lines with the names of the applications you want displayed.

set /p x=Pick: – set the variable name x=Pick that is used in the next line

IF ‘%x%’ == ‘%x%’ GOTO Item_%x% – statement that determines what number in the list you chose and to go to the line (GOTO) that will open the application.

—>>>The above two lines should not be edited<<<—

:Item_1
start /MIN /DC:\Windows\System32 notepad.exe
GOTO Start

All lines starting with :Item_ and their number (in my example 1 to 6) is where you enter the path and executable name of the application to be opened.

The start command has two parts:

MIN will minimize the application when it is opened (NOTE: some applications will ignore this and NOT open minimized).

/DC:\Windows\System32 notepad.exe is where you enter the path and executable name. You will need to edit this parameter with the application you want opened.

GOTO Start – tells the batch file to return to the Start line in the beginning that will allow you to make another selection.

:Item_7
exit
The above lines ends the batch file when you select option 7. Depending on the number of applications in YOUR list, make sure to re-number the list including the last item that is used to exit the batch file.

When finished, save the file and don’t forget to rename the file (right click on the file and select rename) and use .bat as the extension.

Time To Run The Batch File
To run it, double click on the batch file. A command window will appear allowing you to make your selections one at a time (it will loop) by entering the number next to the word Pick, then pressing the Enter key.

After making your selections, don’t forget to select the last number in the list so the batch file will exit.

If you need to re-edit the batch file, just right click on it and select edit (don’t double click to edit). After editing, save the file before closing.

As you can see, creating this batch file can be a handle little utility to have around. It can also be used to not only open applications, but files that you may use frequently (just create another line in the list and add the path to the file with the file name).