Batch Commands Cheatsheet

This cheat sheet provides a list of the most used commands when automating simple tasks and managing system operations.

Batch Commands Cheatsheet
Batch Commands Cheatsheet

Batch Scripts or batch files is a type of scripting language made primarily for the Windows operating system. it is mostly used to automate repetitive tasks by executing a sequence of commands. They can also be used to perform system maintenance and file management.

Batch scripts consist of a series of commands written in plain text mostly using Notepad and are saved using the .bat or .cmd file extensions.

After creating a batch file, you can run it by double-clicking on the file or using the command line to run the file. In this article, we are going to look at some of the most used Batch commands and what they do.

Batch Commands

File and Directory Operations

Command Description
ASSOC Displays or modifies file extension associations.
ATTRIB Displays or changes file attributes.
CACLS Displays or modifies access control lists (ACLs) of files.
COPY Copies files from one location to the other
DEL Deletes files only and not directories
DIR list the contents of a directory
MKDIR create a directory
RMDIR Remove a directory
ROBOCOPY Advanced utility for copying files and directory trees

System Information and Configuration

Command Description
BCDEDIT configures properties in the boot database to control boot loading.
CHKDSK Analyze the disk and provide a status report
CHKNTFS Displays or modifies checking of disk at startup
CMD Open a new command prompt window
COMP Compares the contents of two files based on the file size.
FC List the differences between two files.
FSUTIL Utility for displaying/ configuring file system properties.
GPRESULT Display Group Policy info for machine or user.
SYSTEMINFO Display machine properties and configuration.
TASKLIST List tasks with their name and id (PID)
WMIC Windows Management Instrumentation Command-line Utility

Script Control and Flow

Command Description
CALL Call one batch program from another or call a subroutine
GOTO Directs the command interpreter to a specified label within a batch script.
IF Perform conditional execution in batch programs
LABEL Set or remove a disk label
SHIFT Used to shift the position of replaceable parameters in batch files

User Interaction and Display

Command Description
CLS Used to clear the screen
ECHO Used to display messages in the console or turn command echoing on or off
MORE Display the contents of a file one screen at a time
PAUSE Pauses the execution of a batch file and then displays a message.
TIME Used to display or set the system time
TITLE Set the command prompt window title
VER Display the version of the operating system

Other Utilities

Command Description
COLOR Set the default console foreground and background.
COMPACT Alters the compression of files on NTFS partitions
CONVERT Converts FAT volumes to NTFS
DISKCOMP Compares the contents of two disks.
DISKCOPY Copies the contents of one disk to another
DISKPART Display or configure disk partition properties.
DOSKEY Edits command lines, recalls Windows commands and creates macros
DRIVERQUERY Displays a list of installed device drivers
FIND / FINDSTR Search for strings in files.
MODE Configures a system device.
OPENFILES Displays the files opened by a remote user for a file share.
PRINT Print a text file.
PROMPT Changes the window command prompt.
RECOVER Used when trying to recover readable info from a defective disk.
REM Used to add remarks in batch files hence they cannot be executed.
RENAME / REN Rename files and directories
REPLACE Replace files
SORT Sort inputs
SUBST Used to associate a path with a drive letter
VERIFY Verifies whether files are written correctly to a disk
VOL Display the label of a disk volume and serial number
TREE Display a tree for all subdirectories of the current directory to any level of depth.
TYPE Print the contents of a text file.
NET Provide various network services depending on the command used.
EXIT Exits the console
SET Display the list of environment variables on the current system and also set new environment variables.
Note: The functionalities and options of these commands can vary based on the Windows version used.

Summing Up

This list provides the most used batch commands when automating simple tasks and managing system operations. If we missed any command, please let us know and we'll be sure to add it.

Thank you for reading : )

Great! Next, complete checkout for full access to GeekBits.
Welcome back! You've successfully signed in.
You've successfully subscribed to GeekBits.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.