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

30

winlogo.jpgIn 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.

batch-file-input2To 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, I will select six applications (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).

batch-file-input1

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 \ TextDocument.

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.

batch-file-input3After 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).

Filed under Windows Tips by  #

Comments on How To Create A Batch File That Opens Applications You Choose From A List Leave a Comment

May 31, 2009

r0ck3t3r @ 3:55 pm #

Interesting idea.

August 11, 2009

Ramkumar @ 12:37 am #

Hi, Thank you very much!~

August 13, 2009

Akramul Jakir @ 2:44 pm #

it was nice stuff. thanks a lot………

August 17, 2009

ausi luzinda @ 11:05 am #

its very amazing the ease with which i access applications using these files is
fantastic

June 29, 2010

jack fagnani @ 9:25 pm #

OK can such a batch file be set up to actually launch a program, and then its scan button (a security app) to scan (what drives it will scan would be previously set up in its option/preference tab.

August 5, 2010

Arvind kumar @ 12:16 am #

thk u dear its very nice.

September 6, 2010

christian @ 3:25 am #

hi i know its a folt i made but how can i resolv this it dont wona open.

:Item_4
start /MIN /D"C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe"
GOTO Start

October 21, 2010

Rajesh @ 5:22 am #

its jabardast………………..
Nice Article………..

Jan @ 7:56 am #

@christian you need to do this:
:Item_4
start /MIN /D"C:\Program Files\Malwarebytes' Anti-Malware" mbam.exe
GOTO Start

the diferent is this: start /MIN /D"C:\Program Files\Malwarebytes' Anti-Malware" >>mbam.exe<<

November 10, 2010

JOY @ 3:29 am #

Nice tips… Thanks a lot…………..

November 29, 2010

Nellyzko @ 10:12 am #

Gud work bro, keep it coming. but can you post a short post on the batch files.

December 11, 2010

Roger @ 8:38 pm #

Thanks for your post, it helped me much! I should only say that I found out that it's much better to create batch files with help of Dr.Batcher ( http://www.drbatcher.com ). It supports syntax highlighting, tips on parameters, and lets you convert batch file to EXE, so it's really handy.

December 27, 2010

Jeyanthan @ 7:10 am #

Hey thanks a lot. It works perfect !

March 8, 2011

jeremy @ 5:12 pm #

Now, how do you make the programs run without prompts? Like, if I want ccleaner to run in a certain way, automatically.

jeremy @ 6:45 pm #

START /MIN /D "E:\Program Files\Malwarebytes' Anti-Malware" mbam.exe
GOTO Start

This worked for me!

March 17, 2011

SUNIL VERMA @ 11:42 am #

will you please tell me how i can delete ntdetect.com file with the help of .bat file

May 6, 2011

Vikram @ 8:19 am #

Hello,
I download lots of stuff from Internet, And lots of stuff gets stored in temp folder.I want to delete all the contents of temp folder,I want help in writing a batch file, which would do this.

May 19, 2011

João Regufe Ribeiro @ 3:28 pm #

What a greatfull tip!!!! Thank you!!! It solved a problem that i have
on my job!!!

June 9, 2011

Hitaarth @ 9:33 am #

Hey frenz how to make a batch program which opens photoes instead of application.

Ex.

instea:menu
cls
:start
echo.
echo 1. Notepad
echo 2. Calculator
echo 3. Microsoft Word
echo 4. Windows Media Player
echo 5. Google Chrome
echo 6. Internet Explorer
echo 7. I'm Done
echo.
echo.
set /p x=Pick:
IF '%x%' == '%x%' GOTO Item_%x%

:Item_1
%SystemRoot%\system32\notepad.exe
GOTO Start
d of programs i want to open photoes. Is it possible? how?

Hitaarth @ 9:35 am #

Hey frenz how to make a batch program which opens photoes instead of application.

Ex.

instea:menu
cls
:start
echo.
echo 1. Notepad
echo 2. Calculator
echo 3. Microsoft Word
echo 4. Windows Media Player
echo 5. Google Chrome
echo 6. Internet Explorer
echo 7. I'm Done
echo.
echo.
set /p x=Pick:
IF '%x%' == '%x%' GOTO Item_%x%

:Item_1
%SystemRoot%\system32\notepad.exe
GOTO Start
instead of programs i want to open photoes. Is it possible? how?

September 1, 2011

Ankit @ 10:16 pm #

This is amazing however i want whenever i press 4 then multple excel file should be open which i have instead of one excel file
plz give me a ans it's urget

Ankit @ 10:58 pm #

September 15, 2011

MaX @ 12:43 pm #

@echo off
cls
:start
echo.
echo 1. Photo 1
echo 2. I'm Done
echo.
echo.
set /p x=Pick:
IF '%x%' == '%x%' GOTO Item_%x%

:Item_1
start /MIN /Droot photoname.jpg
GOTO Start

add more obviously. that should work. :)

January 20, 2012

Garou @ 7:41 pm #

I want to open this batch with firefox
@echo off
set google"http://www.google.com/search?q="
set "site=+site:%www.mediafire.com"

set /p "string=Search Details: "

start "" %google%%string%%site%

thank u

April 22, 2012

Stefan @ 5:08 am #

Hi,how to make a list of the sort
1. My computer 4.none
2. Control Panel 5.ping
3. Search 6.none

??

May 22, 2012

Ferry @ 10:26 am #

Could somebody help me creating batchfile to open certain excel file(2007) for 2 seconds then close it saved or without saving then wait for 10 seconds to open it again (same file). Again and again. Then how to stop the batch file? Where's the folder to put this batch file? Thanks

December 5, 2012

joseph @ 6:46 am #

Thanks for this post, i will try that.

August 30, 2014

Ranjit @ 4:59 am #

Hi any one who can help me with
=====================================
I am looking to open this as one of the options in the .bat file.

The locatio of the file is
C:\Program Files\FS Products\DLH Virtual Groups Custom ACARS\kACARS – DLH Virtual.exe
=====================================
The below listed is not working to open the file

@echo off
cls
:start
echo.
echo 1. DLH ACARS
echo 2. Calculator
echo 3. Microsoft Word
echo 4. Microsoft Excel
echo 5. Internet Explorer
echo 6. Firefox
echo info. To exit type 7 and enter
echo.
echo.
set /p x=Pick:
IF '%x%' == '%x%' GOTO Item_%x%

:Item_1
start /MIN /D C:\Program Files\"FS Products"\"DLH Virtual Groups Custom ACARS" "kACARS – DLH Virtual.exe"
GOTO Start

Ranjit @ 5:00 am #

Hi any one who can help me with
=====================================
I am looking to open this as one of the options in the .bat file.

The locatio of the file is
C:\Program Files\FS Products\DLH Virtual Groups Custom ACARS\kACARS – DLH Virtual.exe
=====================================
The below listed is not working to open the file

:Item_1
start /MIN /D C:\Program Files\"FS Products"\"DLH Virtual Groups Custom ACARS" "kACARS – DLH Virtual.exe"
GOTO Start

Ranjit @ 5:03 am #

Hi any one who can help me with
=====================================
I am looking to open this as one of the options in the .bat file.

The locatio of the file is
C:\Program Files\FS Products\DLH Virtual Groups Custom ACARS\kACARS – DLH Virtual.exe
=====================================
Nor this is working to open the file

:Item_1
start /MIN /D "C:\Program Files\FS Products\DLH Virtual Groups Custom ACARS" "kACARS – DLH Virtual.exe"
GOTO Start

Leave a Comment

Fields marked by an asterisk (*) are required.

Subscribe without commenting