File & Directory Operations
Create a new directory
$mkdir <directory>Alias for mkdir, creates a new directory
$md <directory>Create a directory and all required parent directories
$mkdir <path\subpath>Remove an empty directory
$rmdir <directory>Alias for rmdir, removes an empty directory
$rd <directory>Recursively delete a directory and all its contents
$rmdir /s <directory>Quietly delete a directory and all its contents without prompting
$rmdir /s /q <directory>Delete a file
$del <file>Forcefully delete a read-only file
$del /f <file>Delete a file without asking for confirmation
$del /q <file>Delete matching files in all subdirectories
$del /s <pattern>Force-delete files recursively without prompting
$del /f /q /s <pattern>Alias for del, deletes a file
$erase <file>Copy a file to a destination
$copy <source> <destination>Copy a file without prompting to confirm overwrite
$copy /y <source> <destination>Copy a file in binary mode
$copy /b <source> <destination>Concatenate multiple files into one destination file
$copy <file1>+<file2> <destination>Copy files and directory trees
$xcopy <source> <destination>Copy all subdirectories including empty ones
$xcopy <source> <destination> /eCopy subdirectories excluding empty directories
$xcopy <source> <destination> /sCopy hidden and system files
$xcopy <source> <destination> /hCopy without prompting to overwrite destination files
$xcopy <source> <destination> /yCopy quietly without displaying file names
$xcopy <source> <destination> /qAssume destination is a directory if it does not exist
$xcopy <source> <destination> /iCopy excluding files listed in an exclusion file
$xcopy <source> <destination> /exclude:<file>Robust file copy for Windows with advanced options
$robocopy <source> <destination>Copy all subdirectories including empty ones
$robocopy <source> <destination> /eCopy all subdirectories excluding empty ones
$robocopy <source> <destination> /sMirror the source to destination, deleting extra files
$robocopy <source> <destination> /mirMove files and directories, deleting them from source
$robocopy <source> <destination> /moveCopy in restartable mode for interrupted transfers
$robocopy <source> <destination> /zExclude specific files during robocopy
$robocopy <source> <destination> /xf <file>Exclude specific directories during robocopy
$robocopy <source> <destination> /xd <dir>Write robocopy output to a log file
$robocopy <source> <destination> /log:<file>Move or rename a file or directory
$move <source> <destination>Move a file without prompting to overwrite
$move /y <source> <destination>Rename a file or directory
$ren <oldname> <newname>Alias for ren, renames a file or directory
$rename <oldname> <newname>Create a new empty file
$type nul > <file>Create a new file with a single blank line
$echo. > <file>Create a symbolic link to a file
$mklink <link> <target>Create a symbolic link to a directory
$mklink /d <link> <target>Create a hard link to a file
$mklink /h <link> <target>Create a directory junction (soft link for directories)
$mklink /j <link> <target>Display the attributes of a file
$attrib <file>Set a file as hidden
$attrib +h <file>Remove the hidden attribute from a file
$attrib -h <file>Set a file as read-only
$attrib +r <file>Remove the read-only attribute from a file
$attrib -r <file>Set the system attribute on a file
$attrib +s <file>Apply attribute changes recursively to subdirectories
$attrib /s /d <pattern>Compress a file using NTFS compression
$compact /c <file>Uncompress a file using NTFS compression
$compact /u <file>File Viewing & Content
Display the contents of a text file
$type <file>Display file contents one page at a time
$type <file> | moreDisplay file contents one screen at a time
$more <file>Display file contents with extended features enabled
$more /e <file>Search for a specific string in a file
$find "<string>" <file>Search for a string case-insensitively
$find /i "<string>" <file>Search for a string and show matching line numbers
$find /n "<string>" <file>Print lines that do NOT contain the string
$find /v "<string>" <file>Count the number of lines containing the string
$find /c "<string>" <file>Search for a pattern or string in a file
$findstr <pattern> <file>Search for a pattern case-insensitively
$findstr /i <pattern> <file>Search using a regular expression pattern
$findstr /r <pattern> <file>Recursively search files in the current and subdirectories
$findstr /s <pattern> <path>Show the line numbers of matching lines
$findstr /n <pattern> <file>Print lines that do NOT match the pattern
$findstr /v <pattern> <file>Search for a literal string instead of a regex
$findstr /l <string> <file>Search for an exact literal string with spaces
$findstr /c:"<string>" <file>Print only the names of files containing matches
$findstr /m <pattern> <files>Compare the contents of two files
$comp <file1> <file2>Compare two files and display the differences
$fc <file1> <file2>Compare two files in binary mode
$fc /b <file1> <file2>Compare two files ignoring case differences
$fc /i <file1> <file2>Compare text files and display line numbers with differences
$fc /n <file1> <file2>System Information
Display detailed Windows configuration information
$systeminfoDisplay only OS information from systeminfo
$systeminfo | findstr /b /c:"OS"Display the current Windows version
$verDisplay the name of the current computer
$hostnameDisplay the current domain and username
$whoamiDisplay current user, groups, and privileges
$whoami /allDisplay the groups the current user belongs to
$whoami /groupsDisplay the privileges of the current user
$whoami /privDisplay or set the current date
$dateDisplay the current date without prompting to change it
$date /tDisplay or set the current time
$timeDisplay the current time without prompting to change it
$time /tDisplay all environment variables in the current session
$setDisplay the value of a specific environment variable
$set <variable>Set an environment variable for the current session
$set <variable>=<value>Permanently set an environment variable for the user
$setx <variable> <value>Permanently set an environment variable system-wide
$setx <variable> <value> /mDisplay the value of an environment variable
$echo %<variable>%Display the current logged-in username
$echo %USERNAME%Display the computer name
$echo %COMPUTERNAME%Display the operating system name
$echo %OS%Display the processor architecture
$echo %PROCESSOR_ARCHITECTURE%Display the path to the current user's profile directory
$echo %USERPROFILE%Display the path to the temporary files directory
$echo %TEMP%Display the current system PATH
$echo %PATH%Display the operating system name via WMI
$wmic os get captionDisplay the operating system version via WMI
$wmic os get versionDisplay the CPU name via WMI
$wmic cpu get nameDisplay the RAM capacity of each module via WMI
$wmic memorychip get capacityDisplay disk drive models and sizes via WMI
$wmic diskdrive get model,sizeDisplay the system BIOS serial number via WMI
$wmic bios get serialnumberList all installed software products via WMI
$wmic product get nameList all running processes with basic info via WMI
$wmic process list briefList all Windows services with brief info via WMI
$wmic service list briefOpen the System Information graphical tool
$msinfo32Process Management
List all currently running processes
$tasklistFilter processes by executable name
$tasklist /fi "IMAGENAME eq <name>"List only processes with a running status
$tasklist /fi "STATUS eq running"List a specific process by its PID
$tasklist /fi "PID eq <pid>"List processes along with their hosted services
$tasklist /svcList processes with verbose details
$tasklist /vList processes along with DLLs they have loaded
$tasklist /mList processes in CSV output format
$tasklist /fo csvList processes in formatted table output
$tasklist /fo tableTerminate a process by its executable name
$taskkill /im <name>Terminate a process by its PID
$taskkill /pid <pid>Forcefully terminate a process by name
$taskkill /im <name> /fForcefully terminate a process by PID
$taskkill /pid <pid> /fTerminate a process and all its child processes
$taskkill /im <name> /tForcefully terminate a process tree
$taskkill /f /im <name> /tStart a new program or command in a new window
$start <program>Start a program in a new window with a custom title
$start "<title>" <program>Start a program and wait for it to finish
$start /wait <program>Start a program in a minimized window
$start /min <program>Start a program in a maximized window
$start /max <program>Start a program in the background without a new window
$start /b <program>Pause execution for a specified number of seconds
$timeout /t <seconds>Pause without allowing keyboard interruption
$timeout /t <seconds> /nobreakDelay a command by using a ping as a timer
$ping -n 1 127.0.0.1 > nul && <command>Network
Send ICMP echo requests to test connectivity to a host
$ping <host>Send a specified number of ping packets to a host
$ping <host> -n <count>Ping a host continuously until stopped manually
$ping <host> -tPing with a specified packet size
$ping <host> -l <size>Force ping to use IPv4
$ping <host> -4Force ping to use IPv6
$ping <host> -6Resolve the hostname from an IP address when pinging
$ping <host> -aDisplay IP configuration for all network adapters
$ipconfigDisplay full IP configuration details for all adapters
$ipconfig /allRelease the DHCP IP address for all adapters
$ipconfig /releaseRenew the DHCP IP address for all adapters
$ipconfig /renewFlush and reset the DNS resolver cache
$ipconfig /flushdnsDisplay the contents of the DNS resolver cache
$ipconfig /displaydnsRefresh DHCP leases and re-register DNS names
$ipconfig /registerdnsQuery DNS to find the IP address of a domain
$nslookup <domain>Query a specific DNS server for a domain
$nslookup <domain> <dns-server>Query a specific DNS record type
$nslookup -type=<type> <domain>Trace the network route packets take to a host
$tracert <host>Trace route without resolving hostnames
$tracert -d <host>Trace route with a maximum number of hops
$tracert -h <hops> <host>Trace a route and measure packet loss at each hop
$pathping <host>Display active network connections and listening ports
$netstatDisplay all active connections and listening ports
$netstat -aDisplay connections with numeric IP addresses and ports
$netstat -nDisplay all connections with numeric addresses
$netstat -anDisplay the executable involved in each connection
$netstat -bDisplay process IDs associated with each connection
$netstat -oDisplay all connections with addresses and PIDs numerically
$netstat -anoDisplay the routing table
$netstat -rDisplay Ethernet statistics
$netstat -eDisplay per-protocol statistics
$netstat -sDisplay connections for a specific protocol
$netstat -p <protocol>Display a list of computers in the current network
$net viewList shared resources on a specific computer
$net view \\<computer>List all current network connections and mapped drives
$net useMap a network share to a drive letter
$net use <drive>: \\<host>\<share>Disconnect a mapped network drive
$net use <drive>: /deleteDisplay all shared resources on the local computer
$net shareCreate a new network share
$net share <name>=<path>Delete an existing network share
$net share <name> /deleteDisplay the ARP cache showing IP-to-MAC mappings
$arp -aDelete a specific entry from the ARP cache
$arp -d <ip>Add a static ARP entry
$arp -s <ip> <mac>Display the full routing table
$route printAdd a new route to the routing table
$route add <destination> mask <mask> <gateway>Delete a route from the routing table
$route delete <destination>List all saved Wi-Fi profiles
$netsh wlan show profilesDisplay a Wi-Fi profile including the saved password
$netsh wlan show profile name="<ssid>" key=clearConnect to a saved Wi-Fi network
$netsh wlan connect name="<ssid>"Disconnect from the current Wi-Fi network
$netsh wlan disconnectSet a static IP address on a network adapter
$netsh interface ip set address <adapter> static <ip> <mask> <gateway>Set a network adapter to use DHCP
$netsh interface ip set address <adapter> dhcpEnable Windows Firewall for all profiles
$netsh advfirewall set allprofiles state onDisable Windows Firewall for all profiles
$netsh advfirewall set allprofiles state offAdd a firewall rule to allow inbound TCP traffic on a port
$netsh advfirewall firewall add rule name="<n>" protocol=TCP dir=in localport=<port> action=allowDelete a specific firewall rule by name
$netsh advfirewall firewall delete rule name="<n>"Open an FTP connection to a remote host
$ftp <host>Transfer data from a URL (available in Windows 10+)
$curl <url>Download a URL and save it to a file
$curl -o <file> <url>User & Account Management
List all local user accounts
$net userDisplay detailed information about a specific user account
$net user <username>Create a new local user account with a password
$net user <username> <password> /addDelete a local user account
$net user <username> /deleteChange the password for a local user account
$net user <username> <password>Enable a disabled user account
$net user <username> /active:yesDisable a user account
$net user <username> /active:noRequire a password for a user account
$net user <username> /passwordreq:yesSet an expiration date for a user account
$net user <username> /expires:<date>List all local groups
$net localgroupDisplay members of a specific local group
$net localgroup <group>Add a user to a local group
$net localgroup <group> <user> /addRemove a user from a local group
$net localgroup <group> <user> /deleteCreate a new local group
$net localgroup <group> /addDelete a local group
$net localgroup <group> /deleteRun a command as a different user
$runas /user:<domain>\<user> <command>Run a command as the Administrator user
$runas /user:Administrator <command>Display password and logon policy for the local computer
$net accountsSet the maximum password age in days
$net accounts /maxpwage:<days>Set the minimum password length
$net accounts /minpwlen:<length>Services Management
List the status of all services
$sc queryDisplay the status of a specific service
$sc query <service>List all services and drivers
$sc query type= allList all services regardless of their state
$sc query state= allStart a service
$sc start <service>Stop a running service
$sc stop <service>Pause a running service
$sc pause <service>Resume a paused service
$sc continue <service>Set a service to start automatically
$sc config <service> start= autoSet a service to start manually
$sc config <service> start= demandDisable a service from starting
$sc config <service> start= disabledCreate a new service with a binary path
$sc create <service> binPath= "<path>"Mark a service for deletion
$sc delete <service>Set a description for a service
$sc description <service> "<desc>"List all currently running services
$net startStart a Windows service by name
$net start <service>Stop a Windows service by name
$net stop <service>Pause a running service
$net pause <service>Continue a paused service
$net continue <service>Disk & Storage
Open the interactive disk partitioning tool
$diskpartCheck the current drive for errors
$chkdskCheck a specific drive for file system errors
$chkdsk <drive>:Check and fix file system errors on a drive
$chkdsk <drive>: /fLocate bad sectors and recover readable data
$chkdsk <drive>: /rForce dismount before checking (use with /f)
$chkdsk <drive>: /xFormat a disk drive
$format <drive>:Format a drive with the NTFS file system
$format <drive>: /fs:NTFSFormat a drive with the FAT32 file system
$format <drive>: /fs:FAT32Quick format a drive
$format <drive>: /qSet or change the volume label of a drive
$label <drive>: <name>Display the volume label and serial number of a drive
$vol <drive>:Display free and total disk space for a drive
$fsutil volume diskfree <drive>:Create a new file of a specified size in bytes
$fsutil file createnew <file> <size>Assign a drive letter to a folder path
$subst <drive>: <path>Remove a substituted drive letter
$subst <drive>: /dList all current drive substitutions
$substDefragment a drive with progress reporting
$defrag <drive>: /u /vAnalyze a drive without defragmenting
$defrag <drive>: /aBatch Scripting
Turn off command echoing for the rest of the script
$@echo offPrint a message to the console
$echo <message>Print a blank line to the console
$echo.Print the value of a variable
$echo %<variable>%Set a variable in the current batch session
$set <variable>=<value>Prompt the user to input a value for a variable
$set /p <variable>=<prompt>Evaluate an arithmetic expression and store the result
$set /a <variable>=<expression>Execute a command if a condition is true
$if <condition> <command>Execute a command if a file exists
$if exist <file> <command>Execute a command if a file does not exist
$if not exist <file> <command>Execute a command if a variable equals a value
$if %<variable>%==<value> <command>Case-insensitive comparison of a variable to a value
$if /i %<variable>%==<value> <command>Execute a command if the previous command succeeded
$if %errorlevel%==0 <command>Execute a command if a variable is defined
$if defined <variable> <command>Execute a command if a variable is not defined
$if not defined <variable> <command>Execute a command if n1 is greater than n2
$if <n1> gtr <n2> <command>Execute a command if n1 is less than n2
$if <n1> lss <n2> <command>Execute a command if n1 equals n2
$if <n1> equ <n2> <command>Execute a command if n1 does not equal n2
$if <n1> neq <n2> <command>Loop through a set of values
$for %i in (<set>) do <command>Numeric for loop from start to end with step increment
$for /l %i in (<start>,<step>,<end>) do <command>Loop through each line of a file
$for /f %i in (<file>) do <command>Loop through the output of a command
$for /f "tokens=*" %i in ('<command>') do <cmd>Recursively loop through files matching a pattern
$for /r <path> %i in (<pattern>) do <command>Loop through matching directories only
$for /d %i in (<pattern>) do <command>Jump script execution to a labelled section
$goto <label>Define a label to jump to with goto
$:<label>Call and run another batch script
$call <script>.batCall a subroutine defined in the same batch file
$call :<subroutine>Exit the current batch script with an exit code
$exit /b <code>Exit the command prompt session with an exit code
$exit <code>Get the first argument passed to the script, removing quotes
$%~1Get the drive and path of the batch file itself
$%~dp0Get the fully qualified path of the first argument
$%~f1Get the filename without extension from the first argument
$%~n1Get the file extension from the first argument
$%~x1Pause execution and wait for the user to press a key
$pausePrompt the user to press one of a set of characters
$choice /c <chars> /m <message>Begin local environment changes in a script
$setlocalEnd local environment changes and restore original environment
$endlocalEnable delayed variable expansion using !variable! syntax
$setlocal enabledelayedexpansionEnable command extensions for enhanced batch features
$enableextensionsAdd a comment to a batch script (not executed)
$rem <comment>Add a comment using the double-colon syntax
$:: <comment>Redirection & Pipelines
Redirect command output to a file, overwriting it
$<command> > <file>Redirect command output and append it to a file
$<command> >> <file>Use a file as standard input for a command
$<command> < <file>Redirect error output to a file
$<command> 2> <file>Append error output to a file
$<command> 2>> <file>Redirect stderr to the same destination as stdout
$<command> 2>&1Redirect both stdout and stderr to a file
$<command> > <file> 2>&1Discard standard output
$<command> > nulDiscard both standard output and error output
$<command> > nul 2>&1Pipe the output of command1 as input to command2
$<command1> | <command2>Run command2 only if command1 succeeds
$<command1> && <command2>Run command2 only if command1 fails
$<command1> || <command2>Run command1 then command2 unconditionally
$<command1> & <command2>Pipe the output of a command to the clipboard
$<command> | clipPipe output through the more pager
$<command> | morePipe output and filter for a specific string
$<command> | find "<string>"Pipe output and filter using a pattern or regex
$<command> | findstr "<pattern>"Pipe output and sort it alphabetically
$<command> | sortPipe output and sort it in reverse order
$<command> | sort /rSystem Administration
Shut down the local computer
$shutdown /sShut down the computer after a specified delay
$shutdown /s /t <seconds>Restart the local computer
$shutdown /rHibernate the local computer
$shutdown /hLog off the current user
$shutdown /lAbort a pending shutdown
$shutdown /aRemotely shut down another computer
$shutdown /m \\<computer> /sRestart into the Advanced Boot Options menu
$shutdown /r /oRefresh Group Policy settings
$gpupdateForce a full refresh of all Group Policy settings
$gpupdate /forceDisplay the Resultant Set of Policy for the current user
$gpresult /rGenerate an HTML Group Policy report
$gpresult /h <file>.htmlScan and repair protected Windows system files
$sfc /scannowScan system files for integrity without repairing
$sfc /verifyonlyScan and repair the Windows image using DISM
$dism /online /cleanup-image /restorehealthScan the Windows image for corruption
$dism /online /cleanup-image /scanhealthCheck if the Windows image is flagged as corrupted
$dism /online /cleanup-image /checkhealthQuery and display registry key values
$reg query <key>Query a specific registry value
$reg query <key> /v <valuename>Add or update a registry value
$reg add <key> /v <name> /t <type> /d <data>Delete a specific registry value
$reg delete <key> /v <valuename>Delete a registry key and all its values
$reg delete <key>Export a registry key to a .reg file
$reg export <key> <file>.regImport a .reg file into the registry
$reg import <file>.regCopy a registry key and all its subkeys to another location
$reg copy <source> <destination>Open the graphical Registry Editor
$regeditOpen the System Configuration tool
$msconfigOpen the Event Viewer
$eventvwrOpen the Device Manager
$devmgmt.mscOpen the Services management console
$services.mscOpen the Computer Management console
$compmgmt.mscOpen the Disk Management console
$diskmgmt.mscOpen the Task Scheduler
$taskschd.mscOpen the Control Panel
$controlOpen a specific Control Panel applet
$control <applet>Force Windows Update to check for updates immediately
$wuauclt /detectnowDisplay and manage the boot configuration data
$bcdeditList all boot entries in the boot configuration
$bcdedit /enumMiscellaneous
Clear the command prompt screen
$clsDisplay a list of built-in CMD commands with brief descriptions
$helpDisplay help documentation for a specific command
$help <command>Display help and usage information for any command
$<command> /?Change the foreground and background colors of the console
$color <attr>Set black background with green text
$color 0aSet the title of the current command prompt window
$title <text>Change the command prompt text
$prompt <text>Reset the prompt to show current directory and >
$prompt $P$GSet the console window size in columns and lines
$mode con cols=<n> lines=<n>Create a command alias (macro) in CMD
$doskey <alias>=<command>Display the command history for the current session
$doskey /historyList all currently defined macros
$doskey /macrosCopy stdin or piped output to the Windows clipboard
$clipSort the lines of input alphabetically
$sortSort the lines of input in reverse order
$sort /rSort starting from character position <n>
$sort /+<n>Display all file extension associations
$assocDisplay the file type associated with an extension
$assoc .<ext>Associate a file extension with a file type
$assoc .<ext>=<filetype>Display all file type open commands
$ftypeDisplay the open command for a specific file type
$ftype <filetype>Set the open command for a file type
$ftype <filetype>=<command>Find the location of an executable in the PATH
$where <command>Compute the MD5 hash of a file
$certutil -hashfile <file> MD5Compute the SHA256 hash of a file
$certutil -hashfile <file> SHA256Base64-encode a file
$certutil -encode <infile> <outfile>Base64-decode a file
$certutil -decode <infile> <outfile>Encrypt a file using NTFS EFS encryption
$cipher /e <file>Decrypt an EFS-encrypted file
$cipher /d <file>Securely wipe free space on a drive
$cipher /w:<path>Compare two files byte by byte
$fc /b <file1> <file2>Generate a detailed battery usage report
$powercfg /batteryreportAnalyze power usage and generate an energy report
$powercfg /energyList all available power plans
$powercfg /listSet the active power plan
$powercfg /setactive <scheme>