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:
ECHODisplays a text string
REMUsed to comment out a command or make a remark
SETSaves 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
FORPerforms a command on a collection of items
ERRORLEVELContains the returncode of an excuted program
%1-%9When 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:

Leave a Reply

Your email address will not be published. Required fields are marked *