Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 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
  • File Permissions Cheat Sheet
  • Linux Package Management Cheat Sheet
  • System Monitoring Cheat Sheet
View all 31 topics in Operating Systems and CLI