How to Make a Batch File

Level of difficulty: Intermediate

Batch files are files that reduce the difficulty of typing commands every time a user needs some simple tasks performed. Batch files have the .bat file extension. Tasks may range from simple website address launcher, program shut down command, or a compilation of a number of basic tasks. Instead of writing commands again, a user may make batch file, double-click the file, and watch the task performed. Writing a batch file on your Windows Notepad can be easy. You may also create batch files that perform difficult tasks. Follow the steps below for a basic understanding of the process of writing a batch file. For complicated commands, browse the Web for a list of available commands.

Materials Needed:
- Computer
- Windows OS
- Windows Notepad
Step 1
Open the Notepad program in Windows. Click on the 'Start' button on the lower left corner of the Desktop. Navigate to 'Programs', scroll up to 'Accessories', and choose 'Notepad'. The Notepad can also be accessed by typing 'notepad' to the run prompt on the Start panel.
Step 2
Save your Batch File. On the Notepad, go to 'File' and click the 'Save As' option. Choose a file name.
Step 3
Choose the save location of the file.
Step 4
On the 'Save file type as' prompt, choose 'All Files'.
Step 5
Add .bat to the end of the file name before saving. Press 'Save'. The saved file should have a .bat extension at the end.
Step 6
Create a sample batch file by typing '@echo off' on the first line of the batch file. This command prevents any spaces in the batch file to be read as a command by the program.
Step 7
Enter the commands. The following is an example of creating a batch file that will automatically load {variable}.com using your Internet Explorer Web browser. 1. @echo off 2. REM The following will open {variable}.com in a new Internet Explorer window. 3. 'start Iexplore.exe www. {variable}.com' 4. REM The following will open {variable}.com in your default browser. If Internet Explorer is your Web browser and you have another Internet Explorer window open, it will hijack that window. 5. 'start www. {variable}.com'
Step 8
Save the sample file, click 'File', then press 'Save'.
Step 9
The file name of the batch file may be renamed before saving.
Step 10
Run the batch file by double clicking the file on your desktop.