Batch File Documentation

A batch file is a text file with lines of code which the command interpreter executes.

Portions copyright Wikipedia, the free encyclopaedia

Batch File

The shell (usually or cmd.exe) reads the file and executes its commands. A batch file is similar to a shell script in Unix-like operating systems.

DOS batch files have the file extension BAT or CMD.
AUTOEXEC.BAT is a batch file executed during the booting process.

The default behavior of the shell is to print each command to standard output before executing it. Place the command ECHO OFF at the beginning of a batch file to prevent that. In that form, the shell prints only the ECHO OFF command itself. Prefix individual commands with the @ character to prevent these commands from printing. Therefore, most batch files start with the line @ECHO OFF.


Microsoft operating system batch programming has developed along with the releases of the operating systems. These operating systems come up with command interpreters that provide two distinct modes of work. First, the interactive mode in which the user types commands at a prompt which the interpreter executes immediately. Then there is the batch mode, which executes commands in a text file with the extension BAT. The concepts for both functionalities draw ideas of interfaces from the 1980's such as CP/M.

The MS-DOS operating system provided a batch interpreter for the shell ''. Batch programs for MS-DOS are a set of commands interpreted by '' (internal) and separate executables (external). The evolution of batch programming went on through the releases of MS-DOS and into Windows 95, Windows 98, and finally Windows Me.

Windows NT, introduced before MS-DOS 6.0 and not MS-DOS, is the basis of the newest Microsoft Windows versions, Windows 2000 and XP. NT systems include the cmd.exe command-line interpreter, which is somewhat compatible with MS-DOS. Some features are not available, but there are additional commands.

Various other command interpreters exist that provide enhanced command syntax. An example of these is 4DOS.

Several implementations of batch compilers exist to convert batch programs into directly executable programs. The quality of implementation of these compilers varies widely.

The OS/2 operating system contains a command facility related to the ones supplied with Microsoft operating systems.