CMD Intro
The Command Prompt (cmd.exe) is the classic command-line shell of Windows. It reads a command you type, runs it, prints the result and waits for the next one. The same commands can be saved in a batch file (.bat or .cmd) and run as a small program. That is still how many installers, build steps, login scripts and "double-click to fix it" tools on Windows work today.
@echo off
echo Hello from the Command Prompt!
set /a answer=6*7
echo 6 times 7 is %answer%Hello from the Command Prompt!
6 times 7 is 42
echo prints text, set /a does integer arithmetic and stores the result in a variable, and %answer% reads the variable back. The first line, @echo off, stops CMD from printing every command before it runs it; you will see it at the top of almost every batch file.
Why learn CMD in 2026?
PowerShell is the modern, more powerful shell on Windows, so why bother with CMD?
- It is everywhere. Every Windows computer since the 1990s has
cmd.exe, including Windows Server, recovery environments and minimal containers. - Batch files are everywhere. Build scripts,
install.bat,run.cmdlaunchers, CI steps and Group Policy login scripts are often batch files. You will need to read and fix them. - It is fast for small jobs. Changing folders, copying a few files or searching a log is quick to type.
- Many tools assume it. Documentation for compilers, SDKs and command-line tools often shows CMD commands such as
set PATH=…orcd /d.
CMD vs PowerShell vs Windows Terminal
These three names are often confused. Two of them are shells (they understand commands), one is a terminal (the window that shows a shell):
| Command Prompt | PowerShell | Windows Terminal | |
|---|---|---|---|
| What it is | Shell: cmd.exe |
Shell: pwsh.exe (7.x) or powershell.exe (5.1) |
Terminal app (tabs, panes, themes) |
| Scripts | .bat / .cmd batch files |
.ps1 scripts |
none, it hosts shells |
| Passes between commands | Text | .NET objects | n/a |
| Language | Small: set, if, for, goto, call |
Full language: functions, classes, try/catch | n/a |
| Runs on | Windows only | Windows, Linux, macOS (7.x) | Windows 10/11 |
| Status | Maintained for compatibility, no new features | Actively developed | Default terminal in Windows 11 |
On Windows 11, opening "Terminal" starts Windows Terminal, which by default opens a PowerShell tab; you can open a Command Prompt tab from the drop-down next to the tabs. Both shells can run in the same window side by side.
Windows Terminal (the window: tabs, fonts, colours, copy/paste)
├── tab 1: PowerShell ── pwsh.exe ── runs .ps1 scripts
├── tab 2: Command Prompt ── cmd.exe ── runs .bat / .cmd files
└── tab 3: Ubuntu (WSL) ── bash ── runs .sh scriptsA rule of thumb: use PowerShell for new automation, and CMD when you need to read or maintain batch files, when a tool's documentation is written for it, or for quick interactive tasks. The PowerShell course teaches the modern shell, and the Terminal & Command Line course shows each task in CMD, PowerShell, bash and zsh side by side.
Opening the Command Prompt
- Press Win + R, type
cmdand press Enter. - Or open Windows Terminal and choose Command Prompt from the drop-down.
- Or type
cmdin the Start menu. Right-click it and choose Run as administrator for commands that change the system.
The window shows a prompt with the current folder, then a blinking cursor:
Microsoft Windows [Version 10.0.26100.4652]
(c) Microsoft Corporation. All rights reserved.
C:\Users\ada>echo %USERNAME% is using %COMPUTERNAME%
ada is using DESKTOP-7Q2M4KDThat is sample output: your user name, computer name and Windows build will differ. In this course, sessions typed at a prompt look like this: C:\Users\ada> followed by the command and what Windows prints.
How the examples on this site work
CMD can't run inside a web browser, so the CMD playgrounds on this site are simulated: pressing Run shows the output the code produced when it was checked. Every cmd example was recorded by running it as a batch file with Wine's cmd.exe, a reimplementation of the Windows Command Prompt. The batch language (set, if, for, call, goto, redirection, &&/||) behaves exactly as on Windows.
Each example is saved as C:\tad\main.bat and started from the home folder C:\Users\learner (user learner, computer TAD):
@echo off
echo I am %USERNAME% on %COMPUTERNAME%
echo This script is %~f0
cdI am learner on TAD
This script is C:\tad\main.bat
C:\Users\learner
Most examples create a small practice folder, put a few files in it and then work on them, so they don't depend on anything already on disk. A few commands print slightly different messages under Wine than on real Windows (for example the full dir listing, robocopy, attrib, ipconfig or error messages). Those are shown in plain (non-runnable) code blocks with realistic Windows 11 output, labelled as sample output. To experiment freely, open a Command Prompt on a Windows PC and paste the examples in.
Tip: CMD is case-insensitive:
ECHO,Echoandechoare the same command, and%Path%is the same variable as%PATH%. File names are case-insensitive too, because Windows file systems are.
What you will learn
- CMD basics: syntax,
echo, comments and your first batch file. - Files and folders:
cd,dir,mkdir,copy,move,del,xcopy,robocopy,attrib. - Text and pipelines: redirection, pipes,
findstr,find,sort. - Batch scripting: variables, arithmetic,
if,for,for /f, subroutines, arguments, exit codes. - Windows system commands: processes, networking, services, the registry and scheduled tasks.
Learn more: The Terminal on Windows · PowerShell Intro
Test yourself
Which file extensions are used for Command Prompt scripts?
- .ps1
- .sh
- .bat and .cmd
- .exe
What is Windows Terminal?
- A new shell that replaces cmd.exe
- A terminal app that hosts shells such as CMD, PowerShell and WSL in tabs
- The PowerShell 7 executable
- A batch file editor
What does @echo off at the top of a batch file do?
- Turns off all output
- Stops CMD from printing each command before running it
- Deletes the echo command
- Hides error messages