Writing a batch file

A batch file is a small script that can be used to perform several commands, or simplify a complex command which requires many parameters. One executes the batch file like one executes a normal exe-file.
To write a batch file, one has to use a simple text-editor and when saving the script then give it the proper file extension “.BAT”. When writing the batch file one can make use of different builtin commands:

[ECHO](/article/echo-output.html)Displays a text string
REMUsed to comment out a command or make a remark
[SET](/article/environment-variables.html)Saves a value in an environment variables
GOTOJumps to a :LABEL, which can be used to make loops or function calling
IFAllows conditional behavior
CALLUsed for calling other batch files
[FOR](/article/for-operation-files.html)Performs a command on a collection of items
[ERRORLEVEL](/article/errorlevel-return-code.html)Contains the returncode of an excuted program
[%1-%9](/article/batch-file-input-parameters.html)When calling a batch one can provide parameters, which the batch file can access as environment variables
PAUSEStops the execution of the batch file until the user presses a key on the keyboard

Examples of possible ways to use batch files:

Tricks one can use to enhance a batch file: