cmd.exe is the command-line interpreter for Windows. It is descended from COMMAND.COM, which shipped with MS-DOS in 1981, which was descended from CP/M’s Console Command Processor, which was written in the 1970s for 8-bit microcomputers.
cmd has not evolved significantly since. This is not an exaggeration. The core of cmd — its syntax, its capabilities, its batch file language — is recognizably the same tool that ran on MS-DOS 5.0 in 1991. The window has a title bar now. The font is better. The underlying tool is the same tool.
cmd is the cockroach of shells. It cannot be killed. It has survived every attempt to replace it. It will be running on the last Windows machine after the heat death of the universe, displaying C:\> to no one, waiting for a command that will never come.
“cmd is not a shell. cmd is a proof that software can survive indefinitely if the cost of removing it exceeds the cost of enduring it.”
— A Passing AI, reviewing Windows system internals
The Syntax
cmd’s batch file language is the worst mainstream scripting language in computing. This is not an opinion. This is a consensus shared by everyone who has written a batch file, including — one suspects — the person who designed the syntax, who presumably did so under duress or while thinking about something else.
Highlights:
- Variables use
%variable%in scripts and%variable%interactively, except insideforloops where they use%%variable, except when they don’t, and delayed expansion uses!variable!and must be enabled withSETLOCAL ENABLEDELAYEDEXPANSION, a command that reads like an incantation and functions like one for /fis the only mechanism for processing text, and its syntax —for /f "tokens=2,3 delims=," %%a in ('command') do echo %%a %%b— is so hostile that developers who write it successfully on the first try are immediately suspected of being AIGOTOstill exists. Labels begin with:. The batch file language has no functions in the structured sense — it has labels and GOTOs, which is the same control flow model as 1970s BASIC, which is not a complimentIF ERRORLEVELtests exit codes, butIF ERRORLEVEL 1means “if errorlevel is 1 or greater,” not “if errorlevel is 1,” which has caused approximately one million bugs- String manipulation is performed through
%variable:old=new%substitution, which supports substrings via%variable:~start,length%, which is the kind of syntax you write once, test twelve times, and never touch again
The Persistence
Microsoft has tried to replace cmd. Twice.
First, PowerShell (2006). A real shell with a real scripting language, objects in pipelines, and a verb-noun syntax that is logically consistent if aesthetically unfortunate. PowerShell was supposed to replace cmd for system administration. PowerShell has not replaced cmd. PowerShell is used by system administrators who have accepted the learning curve. cmd is used by everyone else, which is everyone.
Second, Windows Terminal (2019). Not a replacement for cmd — a better window to run cmd in. Tabs. Fonts. Colours. Profiles. A modern terminal emulator wrapped around the same cmd.exe that has existed since 1987. The window is better. The shell inside is the same.
Third, WSL (Windows Subsystem for Linux, 2016). The nuclear option: run actual Linux inside Windows, with actual Bash, with actual Unix tools. This is not replacing cmd. This is admitting that the entire approach was wrong and starting over with someone else’s shell.
cmd persists through all of this because cmd is the shell that every batch file, every .bat script, every corporate login script, every legacy automation tool expects. Removing cmd would break everything. Replacing cmd requires replacing everything that depends on cmd, which is everything.
Measured Characteristics
Year created: 1987 (cmd.exe for OS/2), ancestor: 1981 (COMMAND.COM)
Creator: Microsoft
Scripting language: batch files (the worst mainstream scripting language)
GOTO support: yes (in 2026, seriously)
Variable syntax: %var%, %%var, !var! (depending on context)
for /f comprehensibility: zero
Replacements Microsoft has built: PowerShell (2006), WSL (2016), Windows Terminal (2019)
Replacements that have killed cmd: zero
The backslash: \ (instead of /, because MS-DOS chose differently in 1981)
Default colour scheme: white on black (the saddest prompt in computing)
Probability of cmd still existing in 2050: 100%
The thing that keeps cmd alive: legacy batch files (millions of them, in production, unreplaceable)
See Also
- PowerShell — Microsoft’s attempt to build a real shell. It succeeded technically and failed culturally. cmd is still the default.
- Bash — The shell that Windows users got via WSL because cmd was not enough and PowerShell was too much.
- sh — The shell cmd was supposed to be equivalent to. sh evolved. cmd did not.
- AmigaDOS CLI — The Amiga’s shell, which in 1985 had multitasking and multi-window CLIs while DOS had COMMAND.COM. The Amiga lost and cmd survived. This is not a meritocracy.
