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, 134 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
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 | ||
dir /W | • Wide format — up to five names per line • useful for quick visual browse of large directories | ||
dir /P | • Pauses output after each screenful • press any key to continue | ||
dir /Q | Shows the owner of each file alongside the standard listing. | ||
dir /R secret.txt | Reveals alternate data streams (ADS) attached to files. | ||
pushd C:\Temppopd | • pushd saves current directory on a stack and changes to new path• popd restores it |