Windows Command Prompt (cmd.exe) is the built-in command-line interpreter in every version of Windows, providing direct access to the OS through text commands and automatable batch scripts (.bat/.cmd). It remains indispensable for system administration, file management, network diagnostics, and scripting even in a PowerShell era β because it ships on every Windows installation without configuration, runs with minimal overhead, and its batch language integrates tightly with built-in tools like robocopy, icacls, reg, and the entire net command family. The single most important mindset shift: CMD parses each line at read time, not execution time β which is why SETLOCAL EnableDelayedExpansion and !var! syntax exist, and why loop variables appear to "not update" without them.
What This Cheat Sheet Covers
This topic spans 15 focused tables and 168 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: File and Directory Navigation
The three navigation commands β cd, dir, and pushd/popd β cover nearly every exploration need at the prompt. Understanding dir's filter and sort switches turns a bare listing into a precise query.
| Command | Example | Description |
|---|---|---|
cd C:\Users\Admincd .. | Changes the current directory; cd .. moves up one level, cd \ goes to the drive root. | | |
cd /d D:\Projects | /d is required to change both drive letter and directory in a single step. | |
dir C:\Logs | Lists files and folders with size, date, and time; shows disk free space summary. | |
dir C:\Logs\*.log /S /B | /S recurses subdirectories; /B outputs bare paths only β ideal for piping into scripts. | |
dir /A:Hdir /A:-D | /A:H shows only hidden files; /A:-D excludes directories; flags: D H S R A I L. | |
dir /O:-Ddir /O:GS | /O sorts output: N=name, E=ext, G=dirs first, S=size, D=date; prefix - reverses. |