Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

cmd.exe

From Wikipedia, the free encyclopedia
Shell for Windows NT and other operating systems
Not to be confused withCOMMAND.COM.
For other uses, seeCMD.
"Command Prompt" redirects here. For the concept, seeCommand prompt.

Command Prompt (cmd.exe)
Other namesWindows Command Processor
DevelopersMicrosoft,IBM, ReactOS contributors
Initial releaseDecember 1987; 37 years ago (1987-12)
Operating system
PlatformIA-32,x86-64,ARM (and historicallyDEC Alpha,MIPS,PowerPC, andItanium)
PredecessorCOMMAND.COM
TypeCommand-line interpreter

cmd.exe, a.k.a.Command Prompt, is ashellprogram on later versions ofWindows (NT andCE families),OS/2,[1]eComStation,ArcaOS, andReactOS.[2] In some versions of Windows (CE .NET 4.2,[3]CE 5.0[4] andEmbedded CE 6.0[5]) it is referred to as theCommand Processor Shell. Implementation differs between operating systems, but with significant consistency of behavior and available commands.

Older, related operating systems,DOS andWindows 9x, providedCOMMAND.COM as the shell.cmd.exe replacedCOMMAND.COM in the Windows product line with the introduction of NT. Current versions of Windows includePowerShell as an alternative shell that runs side-by-side withcmd.exe.

The initial version ofcmd.exe for Windows NT was developed by Therese Stowell.[6]Windows CE 2.11 was the first embedded Windows release to support a console and a Windows CE version ofcmd.exe.[7] The ReactOS implementation ofcmd.exe is derived from FreeCOM, theFreeDOS command line interpreter.[2]

Use

[edit]

Desktop integration

[edit]

In Windows, the shell is presented in thedesktop viaWindows Terminal or on older versions viaWindows Console.

Concurrent piping

[edit]

In OS/2 and Windows, the shell supportspipes to allow both sides of a pipeline to run concurrently. As a result, it is possible to redirect thestandard error stream. In contrast,COMMAND.COM uses temporary files, and runs the two sides serially, one after the other.

Command separator

[edit]

Multiple commands can be included in a single line using the command separator& or&&.[8]

With the& separator, a subsequent command is executed even if the previous command indicates an error.[9] In the following example, each of the three commands is executed, one after the other, and regardless of their result code.

>CommandA& CommandB& CommandC

With the&& separator, a command must complete successfully for the subsequent command to execute. In the following example,CommandB only executes ifCommandA completes successfully, andCommandC only executes ifCommandB also completes successfully.

>CommandA&& CommandB&& CommandC

Command line limit

[edit]

The shell limits the length of a command line which includes entered text, individualenvironment variables that are inherited by otherprocesses, and all environment variable expansions[10] OnWindows XP and later, the maximum length is 8191 (213-1) characters. On earlier versions, such asWindows 2000 orWindows NT 4.0, the maximum length is 2047 (211-1) characters.

Escaping special characters

[edit]

The shell reserves the following characters asspecial:[8]&<>[]{}^=;!'+,`~ andwhitespace. In some cases, an argument that contains such characters must be enclosed in double quotes to escape from the special character handling. For example:

>echo me& youme'you' is not recognized as an internal or external command,operable program or batch file.>echo"me & you""me & you"

Internal commands

[edit]

The following sections listinternalcommands for implementations of the shell on various operating systems.

OS/2

[edit]
cmd.exe running inOS/2 Window on OS/2 version 1.3

Internal commands in OS/2:[11]

Windows NT family

[edit]
cmd.exe running inWindows Terminal on UkrainianWindows 11

Internal commands in Windows NT and later:[12]

Windows CE

[edit]
Pocket CMD v 3.0 (cmd.exe) onWindows CE 3.0

Internal commands in Windows CE .NET 4.2,[13] Windows CE 5.0[14] and Windows Embedded CE 6.0:[15]

  • attrib
  • call
  • cd
  • chdir
  • cls
  • copy
  • date
  • del
  • dir
  • echo
  • erase
  • exit
  • goto
  • help
  • if
  • md
  • mkdir
  • move
  • path
  • pause
  • prompt
  • pwd
  • rd
  • rem
  • ren
  • rename
  • rmdir
  • set
  • shift
  • start
  • time
  • title
  • type

Thenet command is available as an external command.

ReactOS

[edit]
cmd.exe on ReactOS

Internal commands in ReactOS:[2]

  • ?
  • alias
  • assoc
  • beep
  • call
  • cd
  • chdir
  • choice
  • cls
  • color
  • copy
  • ctty
  • date
  • del
  • delete
  • delay
  • dir
  • dirs
  • echo
  • echos
  • echoerr
  • echoserr
  • 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

[edit]

On Windows,cmd.exe provides varioususer experience enhancments as compared toCOMMAND.COM, including:

  • More detailed error reporting for malformed commands than the genericCOMMAND.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. TheHELP command can then be issued with the error message number to obtain further information.
  • Supports using of arrow keys to scroll through command history. WithCOMMAND.COM, this functionality was only available inDR DOS; viaHISTORY) and later via an external component calledDOSKEY.
  • Addsrotating command-line completion for file and folder paths, where the user can cycle through results for the prefix using theTab, andShift+Tab ↹ for reverse direction.
  • Treats thecaret character (^) as theescape character; the character following it is to be taken literally. There are special characters incmd.exe andCOMMAND.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 withSETLOCAL 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 usingcontrol structures hard and complex.[16] The extensions can be disabled, providing a stricter compatibility mode.
  • TheCOMMAND.COMDELTREE command was merged into therd command via the/Sswitch.
  • SetLocal andEndLocal commands limit the scope of changes to the environment. Changes made to the command line environment afterSetLocal are local to thebatch file.EndLocal restores the previous settings.[17]
  • Thecall command allows subroutines within batch file. TheCOMMAND.COMCALL command only supports calling external batch files.
  • File name parser extensions to theset command are comparable withC shell.[further explanation needed]
  • Theset command can performexpression evaluation.
  • An expansion of thefor command supports parsing files and arbitrary sets in addition to file names.
  • The newpushd andpopd commands provide access past navigated paths similar to forward and back buttons in a web browser orFile Explorer.
  • The conditionalif command can performcase-insensitive comparisons and numeric equality and inequality comparisons in addition to case-sensitive string comparisons. This was available in DR-DOS, but not inPC DOS orMS-DOS.

See also

[edit]

References

[edit]
  1. ^"Notes on using the default OS/2 command processor (CMD.EXE)".www.tavi.co.uk.
  2. ^abc"reactos/reactos".GitHub. December 4, 2021.
  3. ^"Command Processor Shell (Windows CE .NET 4.2)".Microsoft Docs. June 30, 2006.Archived from the original on August 31, 2022.
  4. ^"Command Processor Shell (Windows CE 5.0)".Microsoft Docs. September 14, 2012.Archived from the original on August 28, 2022.
  5. ^"Command Processor Shell (Windows Embedded CE 6.0)".Microsoft Docs. 2012.Archived from the original on September 5, 2022.
  6. ^Zachary, G. Pascal (1994).Showstopper! The Breakneck Race to Create Windows NT and the Next Generation at Microsoft.The Free Press.ISBN 0-02-935671-7.
  7. ^Douglas McConnaughey Boling (2001).Programming Microsoft Windows CE (2nd ed.).Microsoft Press.ISBN 978-0735614437.
  8. ^ab"cmd".Microsoft Learn. September 12, 2023.Archived from the original on November 21, 2023.
  9. ^"Command Redirection, Pipes - Windows CMD - SS64.com".ss64.com. RetrievedSeptember 23, 2021.
  10. ^Command prompt (Cmd.exe) command-line string limitation
  11. ^Microsoft Operating System/2 User's Reference(PDF).Microsoft. 1987.
  12. ^Hill, Tim (1998).Windows NT Shell Scripting.Macmillan Technical Publishing.ISBN 978-1578700479.
  13. ^"Command Processor Commands (Windows CE .NET 4.2)".Microsoft Docs. June 30, 2006.Archived from the original on August 31, 2022.
  14. ^"Command Processor Commands (Windows CE 5.0)".Microsoft Docs. September 14, 2012.Archived from the original on August 31, 2022.
  15. ^"Command Processor Commands (Windows Embedded CE 6.0)".Microsoft Docs. January 5, 2012.Archived from the original on September 6, 2022.
  16. ^"Windows 2000 delayed environment variable expansion".Windows IT Pro. Archived fromthe original on July 13, 2015. RetrievedJuly 13, 2015.
  17. ^"Setlocal".TechNet.Microsoft. September 11, 2009. RetrievedJanuary 13, 2015.

Further reading

[edit]

External links

[edit]
Wikimedia Commons has media related toWindows Command Prompt.
Wikibooks has a book on the topic of:Windows Batch Scripting
Management
tools
Apps
Shell
Services
File systems
Server
Architecture
Security
Compatibility
API
Games
Discontinued
Games
Apps
Others
Spun off to
Microsoft Store
Ecosystem
Interpreters
Terminals
File system navigation
File management
Archiving
Disk management
Processes
Registry
User environment
File contents
Scripting
Networking
Maintenance and care
Boot management
Software development
Miscellaneous
Retrieved from "https://en.wikipedia.org/w/index.php?title=Cmd.exe&oldid=1323392660"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp