Batch file
Batch files are files under the various versions of PC/MS-DOS, Windows, OS/2, and compatible systems which contain commands to be interpreted by the command-line DOS interpreter of those systems. Commands are found one per line (with CR+LF, hex 0D 0A, separating lines), and are executed as if typed directly into the command line. They can include execution of any programs which can be run from the command line, though once the other program starts running its input/output is under that program's control and does not come from the batch file (though the batch file continues executing once the program terminates).
Often the first line of the batch file is @ECHO OFF, which suppresses display of the command lines as they execute. (Early DOS versions didn't support the preceding @ sign which suppresses display of that line, so they just had ECHO OFF which accomplished the desired output suppression for subsequent lines, but did display that line first.)
The traditional file extension for batch files is .bat, but Windows NT introduced a new extension .cmd for batch files, intended to be used for batch files specific to this version of Windows and not intended to be executed on earlier systems. (The old .bat extension works in both old and new systems.) Yet another extension, .btm, was used in the third-party 4DOS and 4NT.
Programs in DOS can exit with a numeric errorlevel, which can be used in batch files to determine the flow of control.
AUTOEXEC.BAT is a special filename which, when placed in the root directory of a drive, causes that particular batch file to be executed automatically when the system is booted from that drive.
See also
- 4DOS compressed batch file
- BATCOM (Wenham Software)
- BAT2EXEC
- BatLite
- Bourne shell script
- Extended Batch Language
- PowerShell
- Windows Script File