|A component of Microsoft Windows|
CMD.EXE in Windows 8
CMD (also known as Command Prompt) is the Microsoft-supplied command-line interpreter on OS/2 and eComStation, Windows CE and on Windows NT-based operating systems (including Windows 2000, XP, Vista, 7, 8, Server 2003, Server 2008, Server 2008 R2 and Server 2012). It is the analog of COMMAND.COM in DOS and Windows 9x systems (where it is also called "MS-DOS Prompt"), or of the Unix shells used on Unix-like systems.
Therese Stowell developed the initial version of CMD.EXE for Windows NT. Although some old DOS commands are unsupported or have been changed (e.g. the functionality of DELTREE was rolled into RD in the form of the /S parameter), CMD.EXE still has a greater number of built-in commands.
The OS/2 and the Windows NT versions of CMD.EXE have more detailed error messages than the blanket "Bad command or file name" (in the case of malformed commands) of COMMAND.COM. In the OS/2 version of CMD.EXE, errors are reported in the current language of the system, their text being taken from the system message files. The HELP command can then be issued with the error message number to obtain further information.
Unlike COMMAND.COM, which is a DOS program, CMD.EXE is a native Windows application usually running in Win32 console. This allows it to take advantage of features available to native programs on the platform that are otherwise unavailable to DOS programs. For example, since CMD.EXE is a native text mode application on OS/2, it can use real pipes in command pipelines, allowing both sides of the pipeline to run concurrently. As a result, it is possible to redirect the standard error in CMD.EXE, unlike COMMAND.COM. (COMMAND.COM uses temporary files, and runs the two sides serially, one after the other.)
In reality, CMD.EXE is a Windows program that acts as a DOS-like command line interpreter. It is generally compatible, but provides extensions which address some of the limitations of COMMAND.COM:
- SETLOCAL/ENDLOCAL commands limit the scope of changes to the environment
- internal CALL allowing subroutines
- filename-parsing extensions to the SET command are comparable to C shell
- expression-evaluation extensions are also provided in the SET command.
- an expansion of the FOR command to support parsing files and arbitrary sets in addition to filenames.
- use of arrow keys to scroll through command history (DOSKEY in COMMAND.COM)
- off-by-default path completion capabilities similar to bash tab completion
- a directory stack accessible with the PUSHD and POPD commands
- IF can perform case-insensitive comparisons and numeric equality and inequality comparisons in addition to case-sensitive string comparisons (the DR-DOS COMMAND.COM supports this as well, but not the IBM and Microsoft COMMAND.COM)
- the ability to escape reserved characters by using the caret character (^)
- delayed variable expansion, fixing DOS idioms that made using control structures hard and complex (CMD.EXE of Windows 2000 and higher)
The extensions can be disabled, providing a stricter compatibility mode.
- 4OS2 – an enhanced, but backwards-compatible replacement for CMD in OS/2
- 4NT / TCC – an enhanced, but backwards-compatible replacement for CMD in Windows NT
- Comparison of command shells
- List of MS-DOS commands
- MSDN Documentation for cmd.exe on Windows XP
- Command Prompt FAQ - Windows
- Full list of CMD commands[discuss]