Catalog / Windows Batch Scripting Cheatsheet
Windows Batch Scripting Cheatsheet
A comprehensive cheat sheet covering essential Windows Batch scripting commands, syntax, and techniques for automating tasks.
Basic Commands & Syntax
Essential Commands
|
Displays messages on the console. |
|
Suppresses command echoing. |
|
Defines or modifies environment variables. |
|
Pauses script execution and waits for user input. |
|
Clears the console screen. |
|
Exits the batch script. |
|
Adds comments to the script. |
Variables
Example:
|
Example:
|
Example:
|
Operators
Arithmetic |
|
Comparison |
|
Logical |
|
Control Flow
Conditional Statements
Example:
|
Example:
|
Example:
|
Looping
Examples:
|
GOTO and Labels
Example:
|
File and Directory Operations
File Manipulation
|
Copies files. |
|
Moves files. |
|
Deletes files. |
|
Renames files. |
|
Displays the content of the file. |
Directory Manipulation
|
Creates a new directory. |
|
Removes a directory. |
|
Changes the current directory. |
|
Lists files and directories in the current directory. |
File Attributes
|
Displays or changes file attributes. |
Advanced Techniques
Subroutines
Example:
|
Error Handling
Example:
|
Command Chaining
Example:
|
Piping and Redirection
|
Redirects output to a file (overwrites existing). |
|
Redirects output to a file (appends). |
|
Pipes output from one command to another. |