A batch file is a script that executes under the MS-DOS command interpreter, typically having a .BAT extension. Batch files are just a list, or batch, or normal DOS commands, although when in this form they collectively make up what is called batch language. Batch files can be simple programs that can simplify or automate repetitive tasks. While not as powerful as a real scripting language, like sh, it is technically complete.
Some MS-DOS commands are designed to work specifically within batch files, although they may have some limited functionality from a normal command line. These commands include IF, FOR, GOTO, SHIFT, CALL, ECHO, and REM.
Unlike Unix shells, DOS, by default, will display each command in a batch file before it executes, as if it had been entered by a human. This functionality, which, while helpful for debugging a batch file, produces an ugly finished product, may be suspended by using the
ECHO OFF command. Although a batch file is just a list of commands, usually a batch file is distinguished by the first command being
@ECHO OFF; the leading @ will prevent that line from being displayed, in addition to the supression of subsequent line echo caused by that line.
The AUTOEXEC.BAT file is a special batch file that is executed on system boot. Or, more correctly, it is executed when COMMAND.COM is run with with a
The Windows NT command interpreter, CMD.EXE, supports a greatly enhanced, although vastly more clumsy, version of the batch language, most notably in the FOR command, as well as in the addition of commands like SETLOCAL and ENDLOCAL.
OS/2 also supports batch files. Those with a .BAT extension are executed by the MDOS command interpreter, COMMAND.COM. Those with a .CMD suffix are executed by the native OS/2 command interpreter, CMD.EXE. .CMD-suffixed files may also be REXX programs, which are also executed natively under OS/2.