Batch file
Dan Tobias (Talk | contribs) (Created page with "{{FormatInfo |formattype=Languages |subcat=Programming Languages |extensions={{ext|bat}}, {{ext|cmd}}, {{ext|btm}} |released=1981 }} '''Batch files''' are files under the var...") |
(Added sample files) |
||
(11 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
|extensions={{ext|bat}}, {{ext|cmd}}, {{ext|btm}} | |extensions={{ext|bat}}, {{ext|cmd}}, {{ext|btm}} | ||
|released=1981 | |released=1981 | ||
+ | |pronom={{PRONOM|x-fmt/413}} | ||
}} | }} | ||
− | + | '''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). | |
− | '''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.) | 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.) | ||
Line 12: | Line 12: | ||
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]]. | 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]] | ||
+ | |||
+ | == Sample files == | ||
+ | * {{DexvertSamples|text/batDOS}} | ||
== References == | == References == | ||
* [[Wikipedia:Batch file|Wikipedia article]] | * [[Wikipedia:Batch file|Wikipedia article]] | ||
* [http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true Batch file reference in Microsoft site] | * [http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true Batch file reference in Microsoft site] | ||
+ | |||
+ | [[Category:Microsoft]] | ||
+ | [[Category:MS-DOS]] |
Latest revision as of 15:34, 28 December 2023
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.
[edit] See also
- 4DOS compressed batch file
- BATCOM (Wenham Software)
- BAT2EXEC
- BatLite
- Bourne shell script
- Extended Batch Language
- PowerShell
- Windows Script File