Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications

Categories

🎓 Certifications
🤖 Artificial Intelligence
☁️ Cloud and Infrastructure
💾 Data and Databases
💼 Professional Skills
🎯 Programming and Development
🔒 Security and Networking
📚 Specialized Topics
CheatGrid
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications
LVLEVEL 0
0/5 XP
GitHub
© 2026 CheatGrid™. All rights reserved.
Privacy PolicyTerms of UseAboutContact

Windows Command Prompt and Batch Scripting Cheat Sheet

Windows Command Prompt and Batch Scripting Cheat Sheet

Back to Operating Systems and CLI
Updated 2026-05-20
Next Topic: Windows PowerShell Scripting and Automation Cheat Sheet

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 NavigationTable 2: File Operations — Create, Copy, Move, DeleteTable 3: Robocopy — Robust File CopyTable 4: ICACLS and File PermissionsTable 5: NET Commands — Network Shares and User ManagementTable 6: Network Diagnostics CommandsTable 7: REG Command — Registry OperationsTable 8: Batch Script FundamentalsTable 9: Variables and ArithmeticTable 10: Conditional Logic — IF CommandTable 11: Loops — FOR CommandTable 12: Subroutines, GOTO, and Script FlowTable 13: Redirection and PipingTable 14: Text Processing — FINDSTR, SORT, MORETable 15: Process and Service Management

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.

CommandExampleDescription
cd (change directory)
cd C:\Users\Admin
cd ..
• Changes the current directory
• cd .. moves up one level, cd \ goes to the drive root. | |
cd /d (cross-drive cd)
cd /d D:\Projects
/d is required to change both drive letter and directory in a single step.
dir
dir C:\Logs
• Lists files and folders with size, date, and time
• shows disk free space summary
dir /S /B
dir C:\Logs\*.log /S /B
• /S recurses subdirectories
• /B outputs bare paths only — ideal for piping into scripts
dir /A
dir /A:H
dir /A:-D
• /A:H shows only hidden files
• /A:-D excludes directories
• flags: D H S R A I L.
dir /O
dir /O:-D
dir /O:GS
• /O sorts output: N=name, E=ext, G=dirs first, S=size, D=date
• prefix - reverses

More in Operating Systems and CLI

  • Windows 11 User Guide Cheat Sheet
  • Windows PowerShell Scripting and Automation Cheat Sheet
  • AWS CLI Cheat Sheet
  • iptables Legacy Linux Firewall Reference Cheat Sheet
  • macOS Usage Cheat Sheet
  • System Administration Cheat Sheet
View all 51 topics in Operating Systems and CLI