In this article you learn how to create and use Windows Batch files by simply using the Windows pre installed notepad editor.
What is a batch file and what can I do with it?
A batch file or MSDOS batch file is a simple list of Windows commands that the computer shall execute.
In Windows the Command Line Interpreter CMD.exe is running a batch file.
Batch files can be used for calling programs that need to be run with parameters or for example executing routines on a file system.
Which commands can be used?
Generally all commands the CMD.exe knows can be used.
To get a full list of the commands go to: Start >> Execute >> cmd.exe
In the command line type ‘help’ and hit Enter. You should see a full list of the available commands.
On the right there is a screenshot from Windows XP showing the available commands (German).
You can also execute other programs from CMD by typing the full absolute path or relative path and hitting Enter.
Be careful when using commands like ‘del’ and ‘format’ and think twice before executing a command like these! They can cause irreversible loss of data, as the ‘del’ or ‘format’ command are not moving deleted files to the Windows Trash Bin!
How to create a batch file?
Batch files can easily be created using the Windows pre-installed editor notepad.exe (Start >> Run >> Notepad.exe).
Open this editor and type the commands you want to excude with the proper parameters.
Write only one command per each line (see example on the left).
In order to create an executable file you have to save the file as *.bat
Don’t forget to put this file extension to your file while saving.
Make sure your file is not a name like MyBatch.bat.txt as the txt is the file extension in this case.
To execute your batch file simply double click on it in Windows Explorer and it will be run by CMD.exe.
To edit your batch file right click on it >> Edit to open it in the Notepad Editor again.
Links
This article is also available in German on Computer-Masters.de
You may also be interested in the following articles:
One thought on “Creating and Using Windows Batch files”