Make a Batch File Run Again

winlogo.jpgIn a previous tip, I showed you how to create a batch file to open multiple applications at one time.

That batch file works great if you want the same applications to ever open at one time.

Merely, what if yous have a number of applications that you apply frequently, and but want to choose from a list, a certain combination of applications to open up at the aforementioned time?

For case, yous have a book report due and you need to research the fabric on the Internet. In this case you desire to open Microsoft Give-and-take and Firefox.

Or, it's fourth dimension to pay the bills, and you need to open up 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 volition appear that will have user input from the command line and open the applications that you lot choosen (equally shown in above screen shot).

To create the batch file, outset, you will want to brand a listing of applications that you lot use frequently.

For this example, I will select six applications (think they can exist whatever corporeality 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 Commencement Menu and right click on the application icon (make sure the Shortcut tab is selected).

batch-file-input1

For Microsoft Office Applications, yous will need to look in the folder where Office is installed. On my calculator, the executable path is:

C:\Program Files\Microsoft Office\Office12 EXCEL.EXE

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

For any application executable that you can not find, use Windows search (in XP and Vista) to aid 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 yous created using notepad, so copy and paste the post-obit code. An explanation of the lawmaking is listed below:

@repeat off
cls
:offset
echo.
echo ane. Notepad
echo 2. Calculator
echo 3. Microsoft Word
echo 4. Microsoft Excel
echo 5. Net Explorer
echo 6. Firefox
echo 7. I'grand Done
echo.
echo.
set /p x=Selection:
IF '%x%' == '%x%' GOTO Item_%10%

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

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

:Item_3
first /MIN /D"C:\Plan 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
showtime /MIN /D"C:\Program Files\Cyberspace Explorer\iexplore.exe" http://www.google.com
GOTO Commencement

:Item_6
outset /MIN /D"C:\Program Files\Mozilla Firefox" firefox.exe http://www.google.com
GOTO Commencement

: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 bare line

repeat 1. Notepad
repeat 2. Calculator
echo 3. Microsoft Word
repeat four. Microsoft Excel
repeat v. Net Explorer
echo 6. Firefox
echo vii. I'yard Done

The in a higher place lines are the applications that will be displayed in the list. Y'all should edited these lines with the names of the applications you want displayed.

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

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

—>>>The in a higher place 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 instance i to half dozen) is where y'all enter the path and executable name of the application to be opened.

The start control has 2 parts:

MIN will minimize the awarding when information technology 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 desire opened .

GOTO Start – tells the batch file to return to the Start line in the starting time that volition allow you to brand some other selection.

:Item_7
exit

The above lines ends the batch file when yous select pick vii. Depending on the number of applications in YOUR list, brand sure to re-number the list including the last particular that is used to exit the batch file.

When finished, salvage the file and don't forget to rename the file (right click on the file and select rename) and use .bat equally the extension.

Fourth dimension To Run The Batch File

To run it, double click on the batch file. A control window will appear allowing you to make your selections one at a time (information technology will loop) by entering the number next to the give-and-take Choice, then pressing the Enter key.

batch-file-input3 Subsequently making your selections, don't forget to select the last number in the listing so the batch file volition leave.

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

As yous can see, creating this batch file tin can be a handle petty utility to have around. It can also be used to not only open up applications, but files that yous may apply frequently (simply create another line in the listing and add the path to the file with the file name).

francisrabing61.blogspot.com

Source: https://www.watchingthenet.com/how-to-create-a-batch-file-that-opens-applications-you-choose-from-a-list.html

0 Response to "Make a Batch File Run Again"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel