Windows CMD Commands Cheat Sheet

The Command Prompt (cmd.exe) commands that still matter — copying and finding files, fixing the network, killing processes, repairing Windows and writing small batch scripts — each explained in one line.

Runs in your browserUpdated
Your valuesEvery example below updates as you type

Navigation & files

11
dir /s /b *.txt

List files of one type in the folder and all subfolders, one full path per line.

cd /d C:\Projects\app

Change folder — /d also switches the drive letter.

mkdir C:\Projects\app\logs

Create a folder (missing parent folders are created too).

copy app.log C:\Projects\app\backup\

Copy a file.

xcopy C:\Projects\app D:\backup\ /e /i /h /y

Copy a folder with all subfolders and hidden files.

robocopy C:\Projects\app D:\backup /mir /r:2 /w:5

destructive Mirror a folder — reliable for large copies; /mir also deletes files missing in the source.

move app.log C:\Projects\app\archive\

Move or rename a file.

del /q C:\Projects\app\*.tmp

destructive Delete files without asking.

rmdir /s /q C:\Projects\app\temp

destructive Delete a folder and everything in it.

type app.log

Print a text file’s content.

tree C:\Projects\app /f

Show the folder structure, including files.

Search & text

5
findstr /s /i /n "error" *.txt

Search files for text — recursive, case-insensitive, with line numbers.

where npm

Show the full path of a program on the PATH (like which).

npm | findstr "error"

Filter a command’s output for lines containing text.

echo %PATH:;=&echo.%

Show each PATH folder on its own line.

fc file1.txt file2.txt

Compare two text files and show the differences.

System & processes

8
tasklist | findstr node

Find running processes by name.

taskkill /im node.exe /f

destructive Force-kill a process by name.

systeminfo

Show Windows version, install date, memory and hotfixes.

sfc /scannow

Check and repair protected Windows system files (run as administrator).

DISM /Online /Cleanup-Image /RestoreHealth

Repair the Windows image when sfc can’t fix files.

chkdsk C: /f

Check the drive for file-system errors and fix them (needs a restart for C:).

shutdown /r /t 0

destructive Restart immediately.

powercfg /batteryreport

Create an HTML battery health report.

Network

8
ipconfig /all

Show IP addresses, DNS servers and adapter details.

ipconfig /flushdns

Clear the DNS cache — fixes many “site not found” problems after DNS changes.

ping -n 4 example.com

Check whether a host responds.

tracert example.com

Show the route packets take to a host.

nslookup example.com

Look up DNS records.

netstat -ano | findstr :3000

Find which process (PID) is using a port.

curl -I https://example.com

Show a site’s HTTP response headers (curl ships with Windows 10+).

netsh wlan show profile name="Home-Network" key=clear

Show a saved Wi-Fi network’s password (“Key Content”).

Variables & scripting

7
set API_URL=value

Set an environment variable for this window.

setx API_URL "value"

Set an environment variable permanently (new windows only).

echo %API_URL%

Print a variable’s value.

for %f in (*.txt) do echo %f

Loop over files (use %%f inside a .bat file).

if exist app.log (echo found) else (echo missing)

Branch on whether a file exists.

npm > out.txt 2>&1

Save both normal output and errors to a file.

npm && echo OK || echo FAILED

Run the next command only if the previous one succeeded (or failed).

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the Windows CMD Commands Cheat Sheet

  1. Type your own values (folder, file, host) in the boxes at the top — every example on the page updates instantly.
  2. Search or jump to a section to find the command you need.
  3. Click Copy to copy a ready-to-run line, or Copy section for a commented block.
  4. Commands marked destructive delete or overwrite data — read the note before running them.

When to use CMD

PowerShell is the modern Windows shell, but Command Prompt is still everywhere: batch files, installers, recovery mode and many documentation snippets assume cmd.exe. Its commands are short and stable — ipconfig, robocopy, sfc and netstat have worked the same way for decades — and they also run inside PowerShell.

Batch file gotchas

Inside a .bat file, loop variables need two percent signs (%%f instead of %f). Variables set inside a parenthesised block need setlocal EnableDelayedExpansion and !var! syntax to see their new value. Save batch files with CRLF line endings — the line ending converter fixes files edited on macOS or Linux.

Run as administrator

Repair and system commands such as sfc, DISM, chkdsk and service changes need an elevated prompt: search for “cmd”, right-click and choose Run as administrator. Compare with the PowerShell cheat sheet.

Tools that pair well with the Windows CMD Commands Cheat Sheet

  • Linux Commands Cheat Sheet — The Linux and bash commands developers use on servers and laptops — files, search, permissions, processes, logs, networking and SSH.
  • Windows Path Converter — Paste a path in any format — C:\Users\me\project, /mnt/c/Users/me/project, /c/Users/me — and get it in every other form, ready to copy: WSL, Git Bash, Cygwin, file URL, UNC and escaped for code.
  • Git Cheat Sheet — Every Git command you use day to day — and the ones you need when something goes wrong — explained in one line.
  • Docker Cheat Sheet — The Docker and Docker Compose commands you reach for every week, explained in one line.

Frequently asked questions

How do I find which program is using a port?
Run netstat -ano | findstr :3000 to get the PID, then tasklist | findstr PID or end it with taskkill /pid PID /f.
What is the difference between xcopy and robocopy?
robocopy is the modern replacement: it resumes, retries, copies permissions and can mirror folders. xcopy is simpler and still works for quick copies.
How do I see a saved Wi-Fi password?
Run netsh wlan show profile name="NetworkName" key=clear — the password is shown as “Key Content”.
Can I install Windows CMD Commands Cheat Sheet as a web app and use it offline?
Yes. Windows CMD Commands Cheat Sheet is an installable web app (PWA) — installed from your browser, not downloaded from an app store. Click Install app at the top of this page in Chrome or Edge (Windows, macOS, Linux, ChromeOS) or on Android, use Share → Add to Home Screen on iPhone and iPad, or File → Add to Dock in Safari 17+ on a Mac. It then opens in its own window with its own icon, and because it runs entirely in your browser it keeps working offline. Firefox on desktop can’t install web apps. How installing works.

Related tools