This article is designed to get the reader started with batch programming under the Windows command line environment. Command line programming is very useful because it allows the programmer to have access to the tens of commands available from the command line, as well as some proper programming structures for:
For example, it is possible to test values that are fed in from the command line, as well as parsing an entire file and performing commands on each token extracted from it. These are tasks usually handled by a higher level software application programming language such as C++ or Java. The batch programming language is rich enough to perform many functions, albeit sometimes in a cumbersome and inefficient manner.
It is, however, perfect for automating command line tasks (backups, copying files, ftp uploads, etc.) and basic editing jobs (adding headers and footers to HTML, publishing thumbnail directories etc.).
For a general overview and first taste of command line programming under Windows and DOS, the following article introduces the topic:
Each file is a plain text file, with the extension .bat, containing one or more commands from a simple 'language'.
The following commands are available for use in batch file programming:
There are no commands for receiving ad-hoc input from the user (the PAUSE command just waits for a keypress), nor any that allow interactivity in terms of mouse handling. For this reason, batch files are typically just used for non-interactive automated tasks.
The following is a list of articles related to individual batch commands:
Typically, layers of commands are built up consisting of batch files calling each other. Recursion is allowed (scripts calling themselves) with the usual caveat that an exit strategy must be provided for.
Despite the primitive origins of batch file programming, the language can be persuaded to perform some complex tasks. These are usually supported by the so-called command extensions which are enabled under Windows XP by default.
The following articles highlight some of these advanced uses: