What is batch script?
A batch script is a text file that contains specific commands that are executed one after the other. It is used to simplify certain repetitive tasks or routines in the Windows, DOS and OS / 2 operating systems and is also used in complex network and system administration. A batch script has the file extension .bat, .cmd, or .btm.
The commands in a batch file are executed by a special interface or shell. These commands can contain 'goto', 'for', 'call', 'echo', 'setlocal' etc. and can use decision and loop constructs. A batch script can be created with any text editor such as Notepad or WordPad and only needs to be saved in plain text format.
A batch file can be run simply by clicking on it or by typing its name into a command line interpreter. A batch script can also be run with arguments. The following are some of the commonly used commands in a batch script:
Echo - To display text on the screen
Invocation - To run a batch script within another script
Goto - Transfers the control or execution sequence to a label or subroutine
If - To test a condition
Pause - wait for a key to be pressed
Rem - To add a comment line to the script
Setlocal - To start a local environment
Endlocal - To end a local environment
Shift - to parse the command line arguments in the script
Start - To run a script with a standard application
Xcopy - For copying files and folders