In DOS, OS/2 and Windows, a batch file is a text file containing a series of commands intended to be executed by the command interpreter. When a batch file is run, the shell program (usually COMMAND.COM or cmd.exe) reads the file and executes its commands, normally line-by-line. A batch file is analogous to a shell script in Unix-like operating systems.
DOS batch files have the filename extension .BAT. Batch files for other environments may have different extensions, e.g. .CMD in Windows NT and OS/2, or .BTM in 4DOS and related shells.
AUTOEXEC.BAT is a special batch file that is executed during the booting process.
The MS-DOS operating system's batch program interpreter is COMMAND.COM. Batch programs for MS-DOS are composed of a relatively simple set of commands interpreted directly by COMMAND.COM (internal commands), and utilities that exist as separate executables (external commands). The evolution of this branch of batch programming proceeded through the releases of MS-DOS, and into Windows 95, Windows 98, and finally Windows Me.
The newest versions of Windows, Windows 2000 and XP, are not based on MS-DOS, but on Windows NT. NT-based systems include the cmd.exe command-line interpreter, which is somewhat compatible with COMMAND.COM. Some MS-DOS features are not available, but there are many additional features and commands not included with MS-DOS or MS-DOS-based versions of Windows. COMMAND.COM is still present under Windows NT operating systems for better backward compatibility.
Various non-Microsoft command interpreters exist that provide enhanced batch program command syntax. An example of these is the 4DOS product.
Several non-Microsoft implementations of batch compilers exist to convert batch programs to directly executable programs. The quality-of-implementation of these compilers varies widely.
The IBM OS/2 operating system contains a text based command facility that is related to the ones supplied with Microsoft operating systems.
echo off is given at the beginning of a batch file to prevent that from happening. In that form, only the echo off command itself would be printed. Since individual commands may be prefixed with the @ character to be prevented from printing, most batch files start with the line @echo off.
@echo off cls echo. echo Hello World, press any key to start AProgram.exe! pause > nul AProgram.exe echo. echo AProgram has finished whatever it was doing. Have fun today!
Scripting languages | DOS on IBM PC compatibles | Microsoft Windows
קובץ אצווה | Batchbestand | バッチファイル | Program wsadowy | Ficheiros batch | Batchfil | 批处理
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Batch file".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world