How to Create a Windows Batch File

By Timothy Banas

A batch file is essentially a small program that you can write to execute a string of commands to save you time. For instance, if you commonly use an email program, an Internet browser, a word processor and a spreadsheet all at the same time, you can create a batch file that will open all of those programs with one click. The possibilities are almost endless, and to create a batch file you only need a Notepad program that comes standard with all versions of Windows.

Step 1

Right-click on your Windows desktop and choose \"New\" and \"Text document\" from the menu that comes up.

Step 2

Write the text for your batch file in the new text document. Batch commands are based on commands that were used in the old Microsoft DOS operating system. Here is a simple example of a batch file that will allow you to drag and drop files onto the batch icon and have the files copied to a backup folder:@ECHO ONmkdir \"C:\\Backup\\\"copy %1 \"C:\\Backup\\\"EXITCopy and paste the above text into your new text document.

Step 3

Save the text file as a \".bat\" file. Click \"File\" in the upper left corner of your text document's window, then choose \"Save as\" from the list of options. Name the file \"abc.bat,\" where \"abc\" is any name you want to give it. The important part is the \".bat,\" which designates the file as a batch file.

Step 4

Drag and drop a file you would like to have copied onto the \"abc.bat\" file icon. Check your \"C\" drive for a folder called \"Backup\" with a copy of the file in it to be sure it worked.

Step 5

Learn the language. Now that you know how to create a basic batch file, learn more commands and begin experimenting with writing complex batch files (see Resources below).