Main Page | See live article | Alphabetical index is the name for the default operating system shell (or command line interpreter) for the MS-DOS/Windows operating system. It also has an additional role, as the first program run after boot, hence being responsible for setting up the system as specified in the autoexec.bat and config.sys configuration files, and being the ancestor of all processes.

As a shell, has two distinct modes of work. First is the interactive mode, in which the user types commands which are then executed immediately. The second is the batch mode, which executes a predefined sequence of commands stored as a text file with the extension .bat. The original concepts for both functionalities is almost certainly derived from the Unix shells, although most programmers would find less able than its counterparts.

Table of contents
1 Syntax
2 Filesystem commands
3 Variables
4 External links


Note that this section does not try to give a full overview to the syntax of, but rather serve as an overview and a mnemonic for the most common and interesting features. Note that all commands are run only after the Enter key is pressed at the end of the line. is case-insensitive, meaning commands can be typed in either case and are all equivalent (so dir, DIR and DiR will all work in the same way).

Filesystem commands

In accordance with's main function as an operating system shell, it includes a number of built-in commands for working with files.

In order to run a program, simply type the name of its executable and then press "Enter" (it is not necessary to use the extension, e.g. nc.exe can be summoned simply as nc). In order to change the current working drive (see Drive letter assignment), type its letter followed by a colon (D:). Other filesystem commands include:

; DIR : Lists the files in the current directory ; CD, CHDIR : Changes the current working directory or displays the currect directory. CD is best since it is shorter. ; COPY : Copies one file to another (if the destination file already exists, MS-DOS asks whether to replace it). (See also XCOPY, an external command that could also copy directory trees) ; MOVE : The same as COPY, but removes the original afterwards. (MS-DOS 6 and higher). ; DEL, ERASE, DELETE : Deletes a file. DEL is best since it is the shortest. (See also DELTREE, an external command which can delete entire directory trees) ; MD, MKDIR : Create a new directory ; RD, RMDIR : Removes an empty directory

Other commands

Note that all commands from the interactive mode can be used in batch files; similarly, one can use batch-file commands directly on the command line, interactively. Therefore, it is impossible to separate the syntax to "interactive" or "batch" commands.

; ECHO : Toggles whether text is displayed (ECHO ON) or not (ECHO OFF). Also displays text on the screen (ECHO text). @ECHO OFF prevents this command from being displayed and only works in a batch file. ; SORT : Sorts the output of another command into a file or the like. ; SET : Sets the value of an environment variable ; PAUSE : Halts execution of the program and displays a message asking the user to press any key to continue. ; SHIFT : Replaces each of the command-line variables with the consequent one (e.g. %0 with %1, %1 with %2 etc. - see below for more information on variables). ; CHOICE : Presents the user with a menu (MS-DOS 6 and higher). Defaults to Y/N. ; CALL : Pauses execution of one batch file, runs another, and returns to the old one and continues.

; COMMAND : The COMMAND command starts a new copy of ; EXIT : Exits from a new copy of, or exits the dos prompt in windows. ; VER : This command is built into and displays the current version.

Control structures

Control structures are mostly used inside batch files, although they can also be summoned interactively.

; FOR : Iteration: repeats a command for each out of a specified set of files. ; GOTO : Moves execution to a specified label. Labels are specified at the beginning of a line, with a colon (:likethis). ; REM : Comment: any text following this command is ignored ; IF : Conditional statement, allows to branch the program execution


Batch files for can be said to have 4 kinds of variables:
  1. ERRORLEVEL - contains the return code of the last program to run (an integer between 0 and 255). Most programs have a certain convention for their return codes (for instance, 0 for a successful execution)
  2. Environment variables - these have the form %VARIABLE%
  3. Command-line parameters - these have the form %0, %1...%9, and initially contain the command line parameters passed to the script (e.g., if the invoking command was "myscript.bat John Doe", then %0 is "myscript.bat", %1 is "John" and %2 is "Doe").
  4. "For" variables - used by loops, have the format %%a (there are variables for all letters). Are defined solely within loops, and iterate over a certain set of values (see below).

See also:
List of DOS commands

External links