Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Cmd.exe
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Shell for Windows NT and other operating systems}} {{distinguish|COMMAND.COM}} {{Other uses|CMD (disambiguation){{!}}CMD}} {{Redirect|Command Prompt|the concept|Command prompt}} {{Lowercase title}} {{use mdy dates|date=January 2024}} {{Infobox software | name = Command Prompt (cmd.exe) | logo = Command prompt icon (windows).png | logo_size = 48px | screenshot = | screenshot_size = 100px | caption = Command Prompt in [[Windows 11]] | developer = [[Microsoft]], [[IBM]], ReactOS contributors | released = {{Start date and age|1987|12}} | other_names = Windows Command Processor | replaces = [[COMMAND.COM]] | operating system = {{Plainlist| * [[Windows NT]] family * [[Windows CE]] family * [[OS/2]] * [[eComStation]] * [[ArcaOS]] * [[ReactOS]]}} | platform = [[IA-32]], [[x86-64]], [[ARM architecture|ARM]] (and historically [[DEC Alpha]], [[MIPS architecture|MIPS]], [[PowerPC]], and [[Itanium]]) | genre = [[Command-line interpreter]] }} '''cmd.exe''', a.k.a. '''Command Prompt''', is a [[shell (computing)|shell]] [[computer program|program]] on later versions of [[Windows]] ([[Windows NT|NT]] and [[Windows CE|CE]] families), [[OS/2]],<ref>{{Cite web|url=http://www.tavi.co.uk/os2pages/cmd.html|title=Notes on using the default OS/2 command processor (CMD.EXE)|website=www.tavi.co.uk}}</ref>, [[eComStation]], [[ArcaOS]], and [[ReactOS]]<ref name="ReactOS" />. In some versions of Windows ([[Windows CE .NET 4.2|CE .NET 4.2]],<ref>{{Cite web|url=https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms879823(v%3dmsdn.10)|title=Command Processor Shell (Windows CE .NET 4.2)|website=Microsoft Docs |date=June 30, 2006 |url-status=live |archive-url=https://web.archive.org/web/20220831154120/https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms879823(v%3dmsdn.10) |archive-date=August 31, 2022}}</ref> [[Windows CE 5.0|CE 5.0]]<ref>{{Cite web|url=https://docs.microsoft.com/en-us/previous-versions/windows/embedded/aa453925(v%3dmsdn.10)|title=Command Processor Shell (Windows CE 5.0)|website=Microsoft Docs |date=September 14, 2012 |url-status=live |archive-url=https://web.archive.org/web/20220828195757/https://docs.microsoft.com/en-us/previous-versions/windows/embedded/aa453925(v%3dmsdn.10) |archive-date=August 28, 2022}}</ref> and [[Windows Embedded CE 6.0|Embedded CE 6.0]]<ref>{{Cite web|url=https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ee499728(v%3dwinembedded.60)|title=Command Processor Shell (Windows Embedded CE 6.0)|website=Microsoft Docs |date=2012 |url-status=live |archive-url=https://web.archive.org/web/20220905191436/https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ee499728(v%3dwinembedded.60) |archive-date=September 5, 2022}}</ref>) it is referred to as the '''Command Processor Shell'''. Implementation differs between operating systems, but with significant consistency of behavior and available commands. Older, related operating systems, [[DOS]] and [[Windows 9x]], provided {{mono|[[COMMAND.COM]]}} as the shell. {{mono|cmd.exe}} replaced {{mono|COMMAND.COM}} in the Windows product line with the introduction of NT. Current versions of Windows include [[PowerShell]] as an alternative shell that runs side-by-side with {{mono|cmd.exe}}. The initial version of {{mono|cmd.exe}} for Windows NT was developed by Therese Stowell.<ref name="Zachary_1994">{{Cite book |title=Showstopper! The Breakneck Race to Create Windows NT and the Next Generation at Microsoft |author-first=G. Pascal |author-last=Zachary |date=1994 |publisher=[[Free Press (publisher)|The Free Press]] |isbn=0-02-935671-7 |url-access=registration |url=https://archive.org/details/showstopperbreak00zach}}</ref> [[Windows CE 2.11]] was the first embedded Windows release to support a console and a Windows CE version of {{mono|cmd.exe}}.<ref>{{Cite book|author=Douglas McConnaughey Boling|year=2001|title=Programming Microsoft Windows CE|edition=2nd|publisher=[[Microsoft Press]]|isbn=978-0735614437}}</ref> The ReactOS implementation of {{mono|cmd.exe}} is derived from FreeCOM, the [[FreeDOS]] command line interpreter.<ref name="ReactOS" /> ==Use== ===Desktop integration=== In Windows, the shell is presented in the [[Windows Desktop|desktop]] via [[Windows Terminal]] or on older versions via [[Windows Console]]. ===Concurrent piping=== In OS/2 and Windows, the shell supports [[Pipeline (Unix)|pipes]] to allow both sides of a pipeline to run concurrently. As a result, it is possible to redirect the [[standard error stream]]. In contrast, {{mono|COMMAND.COM}} uses temporary files, and runs the two sides serially, one after the other. ===Command separator=== Multiple commands can be included in a single line using the command separator {{code|&}} or {{code|&&}}.<ref name="docs.microsoft.com">{{Cite web|url=https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd|title=cmd|website=Microsoft Learn |date=September 12, 2023 |url-status=live |archive-url=https://web.archive.org/web/20231121065635/https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd |archive-date=November 21, 2023}}</ref> With the {{code|&}} separator, a subsequent command is executed even if the previous command indicates an error.<ref>{{Cite web|title=Command Redirection, Pipes - Windows CMD - SS64.com|url=https://ss64.com/nt/syntax-redirection.html|access-date=2021-09-23|website=ss64.com}}</ref> In the following example, each of the three commands is executed, one after the other, and regardless of their result code. <syntaxhighlight lang="doscon"> >CommandA & CommandB & CommandC </syntaxhighlight> With the {{code|&&}} separator, a command must complete successfully for the subsequent command to execute. In the following example, {{code|CommandB}} only executes if {{code|CommandA}} completes successfully, and {{code|CommandC}} only executes if {{code|CommandB}} also completes successfully. <syntaxhighlight lang="doscon"> >CommandA && CommandB && CommandC </syntaxhighlight> ===Command line limit=== The shell limits the length of a command line which includes entered text, individual [[environment variable]]s that are inherited by other [[process (computing)|processes]], and all environment variable expansions<ref>[https://support.microsoft.com/en-us/help/830473/command-prompt-cmd-exe-command-line-string-limitation Command prompt (Cmd.exe) command-line string limitation]</ref> On [[Windows XP]] and later, the maximum length is 8191 (2<sup>13</sup>-1) characters. On earlier versions, such as [[Windows 2000]] or [[Windows NT 4.0]], the maximum length is 2047 (2<sup>11</sup>-1) characters. ===Escaping special characters=== The shell reserves the following characters as [[special character|special]]:<ref name="docs.microsoft.com"/> <code>&<>[]{}^=;!'+,`~</code> and [[whitespace character|whitespace]]. In some cases, an argument that contains such characters must be enclosed in double quotes to escape from the special character handling. For example: <syntaxhighlight lang="doscon">>echo me & you me 'you' is not recognized as an internal or external command, operable program or batch file. >echo "me & you" "me & you" </syntaxhighlight> ==Internal commands== The following sections list [[Shell builtin|internal]] [[command (computing)|commands]] for implementations of the shell on various operating systems. ===OS/2=== [[File:Microsoft OS 2 Version 1.3 cmd.exe OS 2 Window 640x373.png|thumb|{{mono|cmd.exe}} running in '''OS/2 Window''' on OS/2 version 1.3]] Internal commands in OS/2:<ref>{{Cite book|title=Microsoft Operating System/2 User's Reference|date=1987|publisher=[[Microsoft]]|url=http://www.os2museum.com/wp/wp-content/uploads/2011/12/1987-Oct-OS2-1.0-Users_Reference.pdf}}</ref> {{Div col|colwidth=6em}} * [[break (command)|break]] * [[chcp (command)|chcp]] * [[cd (command)|cd]] * [[cd (command)|chdir]] * [[cls (command)|cls]] * [[copy (command)|copy]] * [[date (command)|date]] * [[del (command)|del]] * detach * [[dir (command)|dir]] * [[dpath]] * [[echo (command)|echo]] * [[del (command)|erase]] * [[exit (command)|exit]] * [[FOR (DOS command)|for]] * [[GOTO (DOS command)|goto]] * [[IF (DOS command)|if]] * [[mkdir|md]] * [[mkdir]] * [[path (command)|path]] * [[pause (command)|pause]] * [[prompt (command)|prompt]] * [[rmdir|rd]] * [[rem (command)|rem]] * [[ren (command)|ren]] * [[ren (command)|rename]] * [[rmdir]] * [[set (command)|set]] * [[shift (command)|shift]] * [[start (command)|start]] * [[TIME (command)|time]] * [[TYPE (DOS command)|type]] * [[ver (command)|ver]] * [[verify (command)|verify]] * [[vol (command)|vol]] {{Div col end}} ===Windows NT family=== [[File:Windows11Terminal uk.png|thumb|{{mono|cmd.exe}} running in '''Windows Terminal''' on Ukrainian [[Windows 11]]]] Internal commands in Windows NT and later:<ref>{{Cite book|author-last=Hill|author-first=Tim|title=Windows NT Shell Scripting|date=1998|publisher=[[Macmillan Inc.|Macmillan Technical Publishing]]|isbn=978-1578700479|url-access=registration|url=https://archive.org/details/windowsntshellsc0000hill}}</ref> {{Div col|colwidth=6em}} * assoc * [[break (command)|break]] * [[call (command)|call]] * [[cd (command)|cd]] * [[cd (command)|chdir]] * [[cls (command)|cls]] * color * [[copy (command)|copy]] * [[date (command)|date]] * [[del (command)|del]] * [[dir (command)|dir]] * [[dpath]] * [[echo (command)|echo]] * endlocal * [[del (command)|erase]] * [[exit (command)|exit]] * [[FOR (DOS command)|for]] * [[ftype]] * [[GOTO (DOS command)|goto]] * [[help (command)|help]] * [[IF (DOS command)|if]] * keys * [[mkdir|md]] * [[mkdir]] * [[mklink]] * [[move (command)|move]] * [[path (command)|path]] * [[pause (command)|pause]] * [[pushd and popd|popd]] * [[prompt (command)|prompt]] * [[pushd and popd|pushd]] * [[rmdir|rd]] * [[rem (command)|rem]] * [[ren (command)|ren]] * [[ren (command)|rename]] * [[rmdir]] * [[set (command)|set]] * setlocal * [[shift (command)|shift]] * [[start (command)|start]] * [[TIME (command)|time]] * [[title (command)|title]] * [[TYPE (DOS command)|type]] * [[ver (command)|ver]] * [[verify (command)|verify]] * [[vol (command)|vol]] {{Div col end}} ===Windows CE=== [[File:Microsoft Windows CE Version 3.0 (Build 126) cmd.exe Command Prompt 800x574.png|thumb|Pocket CMD v 3.0 (cmd.exe) on [[Windows CE 3.0]]]] Internal commands in Windows CE .NET 4.2,<ref>{{Cite web|url=https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms879786(v=msdn.10)|title=Command Processor Commands (Windows CE .NET 4.2)|website=Microsoft Docs |date=June 30, 2006 |url-status=live |archive-url=https://web.archive.org/web/20220831154120/https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms879786(v=msdn.10) |archive-date=August 31, 2022}}</ref> Windows CE 5.0<ref>{{Cite web|url=https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms907227(v=msdn.10)|title=Command Processor Commands (Windows CE 5.0)|website=Microsoft Docs |date=September 14, 2012 |url-status=live |archive-url=https://web.archive.org/web/20220831150618/https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms907227(v=msdn.10) |archive-date=August 31, 2022}}</ref> and Windows Embedded CE 6.0:<ref>{{Cite web|url=https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ee505427(v=winembedded.60)|title=Command Processor Commands (Windows Embedded CE 6.0)|website=Microsoft Docs |date=January 5, 2012 |url-status=live |archive-url=https://web.archive.org/web/20220906020659/https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ee505427(v=winembedded.60) |archive-date=September 6, 2022}}</ref> {{Div col|colwidth=6em}} * [[attrib]] * call * cd * chdir * cls * copy * date * del * dir * echo * erase * exit * goto * [[help (command)|help]] * if * md * mkdir * move * path * pause * prompt * [[pwd]] * rd * rem * ren * rename * rmdir * set * shift * start * time * title * type {{Div col end}} The {{mono|[[net (command)|net]]}} command is available as an external command. ===ReactOS=== [[File:ReactOS-0.4.13 cmd.exe Command Prompt 667x434.png|thumb|{{mono|cmd.exe}} on ReactOS]] Internal commands in ReactOS:<ref name="ReactOS">{{Cite web|url=https://github.com/reactos/reactos |title=reactos/reactos |website=GitHub |date=December 4, 2021}}</ref> {{Div col|colwidth=6em}} * ? * [[alias (command)|alias]] * assoc * [[beep (command)|beep]] * call * cd * chdir * [[choice (command)|choice]] * cls * color * copy * ctty * date * del * delete * delay * dir * dirs * echo * echos * {{not a typo|echoerr}} * {{not a typo|echoserr}} * endlocal * erase * exit * for * free * goto * [[history (command)|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 {{Div col end}} ==Comparison with COMMAND.COM== On Windows, {{mono|cmd.exe}} provides various [[user experience]] enhancments as compared to {{mono|COMMAND.COM}}, including: * More detailed error reporting for malformed commands than the generic {{mono|COMMAND.COM}} "[[Bad command or file name]]". In OS/2, errors are reported in the chosen language of the system, their text being taken from the system message files. The <code>[[help (command)|HELP]]</code> command can then be issued with the error message number to obtain further information. * Supports using of arrow keys to scroll through command history. With {{mono|COMMAND.COM}}, this functionality was only available in [[DR DOS]]; via [[HISTORY (CONFIG.SYS directive)|HISTORY]]) and later via an external component called {{mono|[[DOSKEY]]}}. * Adds [[Command-line completion#Rotating completion|rotating command-line completion]] for file and folder paths, where the user can cycle through results for the prefix using the {{keypress|[[tab key|tab]]}}, and {{keypress|[[Shift key|Shift]]|Tab}} for reverse direction. * Treats the [[caret]] character ({{mono|^}}) as the [[escape character]]; the character following it is to be taken literally. There are special characters in {{mono|cmd.exe}} and {{mono|COMMAND.COM}} that are meant to alter the behavior of the command line processor. The caret character forces the command line processor to interpret them literally. * Supports delayed variable expansion with {{code|SETLOCAL EnableDelayedExpansion}}, allowing values of variables to be calculated at runtime instead of during parsing of script before execution (Windows 2000 and later), fixing DOS idioms that made using [[control structures]] hard and complex.<ref name="Delay"/> The extensions can be disabled, providing a stricter compatibility mode. * The {{mono|COMMAND.COM}} <code>[[DELTREE]]</code> command was merged into the <code>[[RMDIR|rd]]</code> command via the {{code|/S}} [[Switch (command line)|switch]]. * {{code|SetLocal}} and {{code|EndLocal}} commands limit the scope of changes to the environment. Changes made to the command line environment after {{code|SetLocal}} are local to the [[batch file]]. {{code|EndLocal}} restores the previous settings.<ref name="SetLocal"/> * The {{code|call}} command allows subroutines within batch file. The {{mono|COMMAND.COM}} {{code|CALL}} command only supports calling external batch files. * File name parser extensions to the {{code|set}} command are comparable with [[C shell]].{{Explain|reason=|date=October 2015}} * The {{code|set}} command can perform [[Expression Evaluation|expression evaluation]]. * An expansion of the <code>[[For loop|for]]</code> command supports parsing files and arbitrary sets in addition to file names. * The new <code>[[PUSHD|pushd]]</code> and <code>[[POPD|popd]]</code> commands provide access past navigated paths similar to forward and back buttons in a web browser or [[File Explorer]]. * The conditional {{code|if}} command can perform [[Case sensitivity|case-insensitive]] comparisons and numeric equality and inequality comparisons in addition to case-sensitive string comparisons. This was available in DR-DOS, but not in [[PC DOS]] or [[MS-DOS]]. ==See also== * {{Annotated link|Comparison of command shells}} * {{Annotated link|List of DOS commands}} ==References== {{Reflist|refs= <!-- <ref name="Zachary_1994">{{Cite book |title=Showstopper! The Breakneck Race to Create Windows NT and the Next Generation at Microsoft |author-first=G. Pascal |author-last=Zachary |date=1994 |publisher=[[Free Press (publisher)|The Free Press]] |isbn=0-02-935671-7 |url-access=registration |url=https://archive.org/details/showstopperbreak00zach}}</ref> --> <ref name="Delay">{{Cite web |title=Windows 2000 delayed environment variable expansion |work=Windows IT Pro |url=http://windowsitpro.com/windows/jsi-tip-3240-windows-2000-delayed-environment-variable-expansion |access-date=2015-07-13 |archive-url=https://web.archive.org/web/20150713131827/http://windowsitpro.com/windows/jsi-tip-3240-windows-2000-delayed-environment-variable-expansion |archive-date=2015-07-13 |url-status=dead}}</ref> <ref name="SetLocal">{{Cite web |title=Setlocal |work=[[Microsoft TechNet|TechNet]] |date=September 11, 2009 |publisher=[[Microsoft]] |url=https://technet.microsoft.com/en-us/library/bb491001.aspx |access-date=2015-01-13}}</ref> }} ==Further reading== * {{Cite book|author1=David Moskowitz|author2=David Kerr|year=1994|title=OS/2 2.11 Unleashed|edition=2nd|publisher=[[Sams Publishing]]|isbn=978-0672304453|ref=none}} * {{Cite book|first=William R.|last=Stanek|year=2008|title=Windows Command-Line Administrator's Pocket Consultant|edition=2nd|publisher=[[Microsoft Press]]|isbn=978-0735622623|ref=none}} ==External links== {{Commons category|Windows Command Prompt}} {{Wikibooks|Windows Batch Scripting}} * {{Cite web|url=https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands|title=Command-line reference A-Z|date=April 26, 2023 |publisher=[[Microsoft]]}} * {{Cite web |url=http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx |title=Cmd |publisher=[[Microsoft]] |work=Microsoft Windows XP Product Documentation |access-date=2006-05-24 |archive-url=https://web.archive.org/web/20110902070525/http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx |archive-date=2011-09-02 |url-status=dead}} * {{Cite web |url=http://windows.microsoft.com/en-us/windows/command-prompt-faq#1TC=windows-7 |title=Command Prompt: frequently asked questions |publisher=[[Microsoft]] |work=windows Help |access-date=2015-04-20 |archive-url=https://web.archive.org/web/20150422041137/http://windows.microsoft.com/en-us/windows/command-prompt-faq#1TC=windows-7 |archive-date=2015-04-22 |url-status=dead}} * {{Cite web |url=https://ss64.com/nt/ |title=An AβZ Index of the Windows CMD command line |publisher=SS64.com}} * {{Cite web |url=https://windowscmd.com/ |title=Windows CMD.com β Hub of Windows Commands |publisher=windowscmd.com |access-date=2022-01-04 |archive-date=2022-01-11 |archive-url=https://web.archive.org/web/20220111180551/https://windowscmd.com/ |url-status=dead }} * [https://www.colorconsole.de/console/en/index.htm Most important CMD commands in Windows - colorconsole.de] {{Microsoft Windows components}} {{Windows commands}} [[Category:Command shells]] [[Category:OS/2 command shells]] [[Category:Windows command shells]] [[Category:OS/2 commands]] [[Category:OS/2 files]] [[Category:Windows commands]] [[Category:Windows files]] [[Category:Windows components]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Annotated link
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Commons category
(
edit
)
Template:Distinguish
(
edit
)
Template:Div col
(
edit
)
Template:Div col end
(
edit
)
Template:Explain
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Keypress
(
edit
)
Template:Lowercase title
(
edit
)
Template:Main other
(
edit
)
Template:Microsoft Windows components
(
edit
)
Template:Mono
(
edit
)
Template:Not a typo
(
edit
)
Template:Other uses
(
edit
)
Template:Redirect
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Sister project
(
edit
)
Template:Template other
(
edit
)
Template:Use mdy dates
(
edit
)
Template:Wikibooks
(
edit
)
Template:Windows commands
(
edit
)