A batch file is a text file containing a series of commands that are executed by the command interpreter on MS-DOS, IBM OS/2, or Microsoft Windows systems.
Batch files are text-based scripts, usually saved with the .bat
, .cmd
, or .btm
filename extension. They are executed by the command processor (typically COMMAND.COM
on MS-DOS and earlier versions of Windows, cmd.exe
on IBM OS/2 and later version of Windows). Note that, while batch files are still supported under Windows, recent versions have the much more expansive PowerShell.
Example
This is the source code to a typical "Hello world" program in batch programming:
@ECHO off
ECHO Hello World!
PAUSE
Note the !
may not display if delayed expansion is enabled.
Tag usage
The tag batch-file can be used for programming-related problems in writing a batch script file for a Windows-based operating system. Please avoid "suggest a book"-type questions. Note the batch-file tag is not to be used for questions referring to a "batch of files" or referring to the "Spring Batch" framework but for questions related to the shell language only.
Useful links
- WikiPedia: Batch file article
- WikiBooks: Windows Batch Scripting
- WikiHow: How to write a batch file
- ComputerHope: Batch File Help
- MakeUseOf: How to write a simple batch file
- TutorialsPoint: Batch Script Tutorial
- DosTips: Windows Batch Guide
- SS64: NT Command Documentation
- Rob van der Woude: Batch Techniques
- Steve Jansen: Guide to Windows Batch Scripting
- Microsoft: Windows XP Batch Reference
- Microsoft: Windows XP Command Reference
- Microsoft: Windows Command Reference (Windows 8.1+, Windows Server 2008+
- How does the Windows Command Interpreter (CMD.EXE) parse scripts?
- How can I debug a .BAT script?
See also: script