Cmd.exe
| Company type | Command-line interpreter |
|---|---|
| Industry | Software |
| Founder | Therese Stowell |
| Products | Command-line shell for Windows NT, Windows CE, OS/2, eComStation, ArcaOS, ReactOS |
cmd.exe, often referred to as Command Prompt, serves as a command-line interpreter in later editions of Windows (notably within the Windows NT and Windows CE series), as well as in OS/2, eComStation, ArcaOS, and ReactOS. In certain Windows variants, including Windows CE .NET 4.2, Windows CE 5.0, and Windows Embedded CE 6.0, it is designated the Command Processor Shell. Despite differences in implementation across these platforms, its commands and functionalities remain predominantly uniform.
Earlier operating systems such as DOS and Windows 9x relied on as their command interpreter. The introduction of Windows NT marked the replacement of by . In addition to , contemporary Windows systems also offer PowerShell as a supplementary shell environment.
The original version of for Windows NT was created by Therese Stowell. The embedded Windows release, Windows CE 2.11, was the first to incorporate a console along with a Windows CE adaptation of . ReactOS’s iteration of is derived from FreeCOM, the command interpreter utilized by FreeDOS.
Desktop access
Within Windows, users launch the shell through the desktop interface, commonly via Windows Terminal, or on legacy versions, through the Windows Console application.
Simultaneous piping
On platforms like OS/2 and Windows, the shell supports pipes that execute both ends concurrently, allowing for redirection of the standard error stream. This contrasts with , which processes pipeline commands sequentially using temporary files.
Separating commands
It is possible to chain multiple commands on a single line using either or . When employing , all commands execute regardless of any errors encountered:
<syntaxhighlight lang="doscon"> >CommandA & CommandB & CommandC </syntaxhighlight>
Conversely, with , each command executes only if the preceding command completes successfully:
<syntaxhighlight lang="doscon"> >CommandA && CommandB && CommandC </syntaxhighlight>
Maximum command length
The shell imposes a maximum length on command lines—including both input text and expanded environment variables—capped at 8191 characters on Windows XP and subsequent versions, while earlier editions such as Windows 2000 and Windows NT 4.0 restrict this to 2047 characters.
Handling special characters
Certain characters are reserved within the shell environment: &<>[]{}^=;!'+,`~ along with whitespace. Arguments containing these symbols typically require enclosing in double quotes to prevent parsing errors:
<syntaxhighlight lang="doscon"> >echo me & you me 'you' is not recognized as an internal or external command
>echo "me & you" "me & you" </syntaxhighlight>
Internal commands
This segment enumerates the built-in commands available within various shell implementations across different operating systems.
OS/2
The following are internal commands supported in OS/2:
- break
- chcp
- cd, chdir
- cls
- copy
- date
- del, erase
- detach
- dir
- dpath
- echo
- exit
- for
- goto
- if
- md, mkdir
- path
- pause
- prompt
- rd, rmdir
- rem
- ren, rename
- set
- shift
- start
- time
- type
- ver
- verify
- vol
Windows NT series
The internal commands available in Windows NT and subsequent versions include:
- assoc
- break
- call
- cd, chdir
- cls
- color
- copy
- date
- del, erase
- dir
- dpath
- echo
- endlocal
- exit
- for
- ftype
- goto
- help
- if
- keys
- md, mkdir
- mklink
- move
- path
- pause
- popd, pushd
- prompt
- rd, rmdir
- rem
- ren, rename
- set, setlocal
- shift
- start
- time
- title
- type
- ver
- verify
- vol
Windows CE
The following internal commands are present in Windows CE .NET 4.2, Windows CE 5.0, and Windows Embedded CE 6.0:
- attrib
- call
- cd, chdir
- cls
- copy
- date
- del
- dir
- echo
- erase
- exit
- goto
- help
- if
- md, mkdir
- move
- path
- pause
- prompt
- pwd
- rd, rmdir
- rem
- ren, rename
- set
- shift
- start
- time
- title
- type
The command functions as an external utility.
ReactOS
ReactOS supports the following internal commands:
- ?
- alias
- assoc
- beep
- call
- cd
- chdir
- choice
- cls
- color
- copy
- ctty
- date
- del
- delete
- delay
- dir
- dirs
- echo
- echos
endlocal
erase
exit
for
free
goto
history
if
memory
md
mkdir
mklink
move
path
pause
popd
prompt
pushd
rd
rmdir
rem
ren
rename
replace
screen
set
setlocal
shift
start
time
timer
title
type
ver
verify
vol
Comparison with COMMAND.COM
Compared to , Windows' provides numerous improvements in user interaction, such as:
- Enhanced error diagnostics for incorrect commands beyond the generic "Bad command or file name." OS/2 delivers error messages localized in the system language with explanations sourced from system files. The
HELPfunction can be invoked with the error code for additional information.
- Support for arrow keys to navigate through previous commands, a feature formerly limited to systems like DR DOS using HISTORY or third-party utilities.
- Command-line completion cycles through file and directory names by utilizing the and keys.
- The caret symbol () acts as an escape character, allowing literal interpretation of subsequent characters and improving command parsing.
- Delayed variable expansion is enabled via , permitting variables to be evaluated during execution rather than at parse time—available from Windows 2000 onward—thus enhancing scripting flexibility.[1] This feature can be disabled to maintain strict backward compatibility.
- . Commands like and confine environment variable modifications to the batch file's scope, restoring prior settings after completion.[2]
- . The command supports invoking subroutines within batch scripts, whereas COMMAND.COM's CALL is limited to external batch files only.
- . Extensions to the file name parser within resemble capabilities found in the C shell, enabling expression evaluation.
- . The
forcommand is capable of iterating over files and arbitrary sets beyond just file names.
- . Newly introduced
pushdandpopdcommands facilitate directory stack navigation similar to forward/backward browsing or the navigation features in File Explorer.
- . The conditional command supports case-insensitive string comparisons along with numeric equality and inequality tests, extending functionality beyond earlier DOS implementations.