A batch file consists of commands stored in a plain text file to be executed by the command-line interpreter. The term “batch” refers to non-interactive execution. Batch files are used to automate repetitive tasks.
Batch files have the .bat extension in DOS, OS/2 and Microsoft Windows operating systems. They are also called scripts, batch programs, command files, and shell scripts. Batch files may use conditional branching and looping constructs like IF, FOR, and GOTO labels.
In DOS, run batch files by typing the filename and .bat extension at the command line interface. Early Windows versions relied on DOS to perform operations like repairing, optimizing or reinstalling Windows.
Working with batch files can be dangerous to personal and system files. View unknown batch files only in a text editor, not by double-clicking, to avoid malware attacks. Software may reference batch files to copy, delete or access data, launch applications or stop processes.
The .bat format executes DOS batch files containing code to initialize Windows applications and resources. Code lines in a batch file run applications, built-ins and utilities sequentially. The Autoexec.bat file initializes DOS at startup. In Unix, shell scripts serve a similar function as batch files.
Basic batch file commands can modify system settings, launch software or websites. Tools like PowerShell and Bash allow creating advanced scripts.