70+ Essential Windows CMD Commands
File and Directory Commands
dir Lists files/directories.
:: Basic: List all files with details
dir /a
:: Advanced: Find specific file types recursively
dir *.txt /s /pcd Changes directory.
:: Basic: Navigate to a folder
cd C:\Users
:: Advanced: Switch to path with spaces
cd "C:\Program Files (x86)"mkdir/md Creates a directory.
:: Basic: Create a single folder
mkdir Data
:: Advanced: Create nested folders
mkdir Parent\Child\Grandchildrmdir/rd Deletes a directory.
:: Basic: Remove empty folder
rmdir Data
:: Advanced: Delete non-empty folder
rmdir /s /q Datadel Deletes files.
:: Basic: Delete a single file
del temp.txt
:: Advanced: Delete all .log files silently
del *.log /qcopy Copies files.
:: Basic: Copy a file
copy file.txt D:\Backup
:: Advanced: Copy multiple files with overwrite
copy *.txt D:\Backup /yxcopy Extended copy for files/directories.
:: Basic: Copy a directory
xcopy Data D:\Backup
:: Advanced: Copy with hidden files and subdirs
xcopy Data D:\Backup /E /Hmove Moves/renames files.
:: Basic: Move a file
move file.txt D:\Archive
:: Advanced: Rename multiple files
move *.txt *.bakattrib Changes file attributes.
:: Basic: Hide a file
attrib +h secret.txt
:: Advanced: Make folder read-only and hidden
attrib +r +h Dataren Renames files/directories.
:: Basic: Rename a file
ren old.txt new.txt
:: Advanced: Bulk rename files
ren *2023*.txt *2024*.txtSystem Information Commands
systeminfo Shows system configuration.
:: Basic: Display OS name
systeminfo | find "OS Name"
:: Advanced: Export full info to file
systeminfo > sysinfo.txthostname Shows computer name.
:: Basic: Get hostname
hostname
:: Advanced: Log device name in script
echo %COMPUTERNAME% > device.txtver Shows Windows version.
:: Basic: Check version
ver
:: Advanced: Verify version in script
ver | findstr "10.0"set Manages environment variables.
:: Basic: View all variables
set
:: Advanced: Add custom path
set PATH=%PATH%;C:\Toolswmic Performs system admin tasks.
:: Basic: Get CPU info
wmic cpu get name
:: Advanced: List installed software
wmic product get name,versionwhoami Shows current user.
:: Basic: Display username
whoami
:: Advanced: Get user SID
whoami /usertasklist Lists running processes.
:: Basic: Show all processes
tasklist
:: Advanced: Filter specific process
tasklist /fi "IMAGENAME eq notepad.exe"Network Commands
ipconfig Shows IP configuration.
:: Basic: Display IP details
ipconfig
:: Advanced: Release and renew IP
ipconfig /release && ipconfig /renewping Tests network connectivity.
:: Basic: Ping a website
ping google.com
:: Advanced: Continuous ping
ping -t google.comtracert Traces route to a host.
:: Basic: Trace to domain
tracert google.com
:: Advanced: Trace without DNS
tracert -d 8.8.8.8netstat Shows connections/ports.
:: Basic: List active connections
netstat -a
:: Advanced: Show process IDs
netstat -a -onslookup Queries DNS.
:: Basic: Resolve domain
nslookup google.com
:: Advanced: Query specific DNS server
nslookup google.com 8.8.8.8arp Manages ARP cache.
:: Basic: Show ARP table
arp -a
:: Advanced: Delete ARP entry
arp -d 192.168.1.1route Manages routing table.
:: Basic: Display routing table
route print
:: Advanced: Add persistent route
route add 10.0.0.0 MASK 255.255.255.0 192.168.1.1 /pnet use Maps network drives.
:: Basic: Map a drive
net use Z: \\server\share
:: Advanced: Map with credentials
net use Z: \\server\share /user:domain\user passwordnetstat -an Shows connections numerically.
:: Basic: List listening ports
netstat -an | find "LISTENING"
:: Advanced: Log connections
netstat -an > netlog.txtnetsh Configures network settings.
:: Basic: Show Wi-Fi profiles
netsh wlan show profiles
:: Advanced: Export Wi-Fi profile
netsh wlan export profile name="MyWiFi" folder=C:\WiFiDisk and Drive Commands
chkdsk Checks/repairs disk errors.
:: Basic: Scan drive
chkdsk C:
:: Advanced: Fix errors on reboot
chkdsk C: /f /rdiskpart Manages disks/partitions.
:: Basic: List disks
diskpart
list disk
:: Advanced: Create partition
diskpart
select disk 1
create partition primaryformat Formats a drive.
:: Basic: Format USB
format D: /fs:NTFS
:: Advanced: Quick format with label
format D: /fs:NTFS /q /v:MyUSBlabel Sets volume label.
:: Basic: Change label
label D: MyDrive
:: Advanced: Remove label
label D:vol Shows volume info.
:: Basic: Display volume details
vol C:
:: Advanced: Pipe to file
vol C: > volume.txtfsutil Manages file system.
:: Basic: Check drive type
fsutil fsinfo drivetype C:
:: Advanced: Disable 8.3 names
fsutil 8dot3name set C: 0Task and Process Management Commands
taskkill Terminates processes.
:: Basic: Kill process by name
taskkill /IM notepad.exe
:: Advanced: Force-kill by PID
taskkill /PID 1234 /FInvestigation Context: Detect malicious
taskkilluse (e.g., targetingMsMpEng.exe) in Defender XDR/Sentinel.
DeviceProcessEvents
| where ProcessCommandLine contains "taskkill /IM MsMpEng.exe"
| project Timestamp, DeviceName, ProcessCommandLineschtasks Manages scheduled tasks.
:: Basic: Create daily task
schtasks /create /tn MyTask /tr notepad.exe /sc daily
:: Advanced: Delete task
schtasks /delete /tn MyTask /fsc Controls services.
:: Basic: Check service status
sc query wuauserv
:: Advanced: Start a service
sc start wuauservshutdown Performs shutdown/restart/logoff.
:: Basic: Shutdown in 60s
shutdown /s /t 60
:: Advanced: Cancel shutdown
shutdown /astart Starts program in new window.
:: Basic: Open Notepad
start notepad
:: Advanced: Open URL in browser
start https://google.compause Pauses batch file.
:: Basic: Pause script
pause
:: Advanced: Pause with message
echo Pausing... & pausetimeout Adds delay in scripts.
:: Basic: Wait 10 seconds
timeout /t 10
:: Advanced: Non-interactive wait
timeout /t 10 /nobreakUser and Security Commands
net user Manages user accounts.
:: Basic: Add user
net user JohnDoe Pass123 /add
:: Advanced: Disable user
net user JohnDoe /active:nonet localgroup Manages group memberships.
:: Basic: Add to Administrators
net localgroup Administrators JohnDoe /add
:: Advanced: List group members
net localgroup Administratorsrunas Runs program as another user.
:: Basic: Run Notepad as Admin
runas /user:Admin notepad.exe
:: Advanced: Run with saved credentials
runas /user:Admin /savecred notepad.execacls Modifies file permissions.
:: Basic: Grant read access
cacls file.txt /e /p Everyone:r
:: Advanced: Deny write access
cacls file.txt /e /d Everyoneicacls Advanced file permissions.
:: Basic: Grant full control
icacls file.txt /grant Users:F
:: Advanced: Remove permissions
icacls file.txt /remove Userslock Locks workstation.
:: Basic: Lock session
rundll32.exe user32.dll,LockWorkStation
:: Advanced: Lock in script
echo Locking... & rundll32.exe user32.dll,LockWorkStationgpupdate Updates Group Policy.
:: Basic: Refresh policy
gpupdate
:: Advanced: Force user and computer policy
gpupdate /force /target:bothsecedit Applies security templates.
:: Basic: Export current config
secedit /export /cfg sec.cfg
:: Advanced: Apply template
secedit /configure /db secedit.sdb /cfg security.infPower and Shutdown Commands
powercfg Manages power settings.
:: Basic: Generate battery report
powercfg /batteryreport
:: Advanced: Set power plan
powercfg /setactive 381b4222-f694-41f0-9685-ff5bb260df2eshutdown /s /t 0 Immediate shutdown.
:: Basic: Shutdown now
shutdown /s /t 0
:: Advanced: Shutdown with message
shutdown /s /t 0 /c "System maintenance"shutdown /r /t 0 Immediate restart.
:: Basic: Restart now
shutdown /r /t 0
:: Advanced: Restart with message
shutdown /r /t 0 /c "Applying updates"shutdown /l Logs off user.
:: Basic: Log off
shutdown /l
:: Advanced: Log off in script
echo Logging off... & shutdown /lWindows Troubleshooting Commands
sfc /scannow Repairs system files.
:: Basic: Scan and repair
sfc /scannow
:: Advanced: Verify specific file
sfc /verifyfile C:\Windows\System32\kernel32.dllDISM Repairs Windows images.
:: Basic: Check health
DISM /Online /Cleanup-Image /CheckHealth
:: Advanced: Restore health
DISM /Online /Cleanup-Image /RestoreHealthcleanmgr Launches disk cleanup.
:: Basic: Open cleanup GUI
cleanmgr
:: Advanced: Auto-clean temporary files
cleanmgr /sagerun:1eventvwr Opens Event Viewer.
:: Basic: Launch Event Viewer
eventvwr
:: Advanced: Open specific log
eventvwr /c:Systemmsinfo32 Shows system info.
:: Basic: Open System Information
msinfo32
:: Advanced: Export to file
msinfo32 /report sysinfo.txtAdvanced and Miscellaneous Commands
tree Displays folder structure.
:: Basic: Show folder tree
tree C:\Data
:: Advanced: Include files
tree C:\Data /fecho Displays messages or toggles echoing.
:: Basic: Print message
echo Hello, World!
:: Advanced: Disable echoing
echo offcls Clears CMD screen.
:: Basic: Clear screen
cls
:: Advanced: Clear in script
echo Clearing... & clstitle Sets CMD window title.
:: Basic: Set title
title My Script
:: Advanced: Dynamic title
title Backup_%DATE%color Changes CMD colors.
:: Basic: Green text on black
color 0A
:: Advanced: Blue on white
color 1Fexit Closes Command Prompt.
:: Basic: Exit CMD
exit
:: Advanced: Exit with code
exit /b 1prompt Changes CMD prompt.
:: Basic: Set default prompt
prompt $P$G
:: Advanced: Custom prompt
prompt $T$Ghelp Shows command help.
:: Basic: Help for dir
help dir
:: Advanced: List all commands
helpCMD Scripting and Batch Commands
if Conditional logic in scripts.
:: Basic: Check file existence
if exist file.txt echo Found
:: Advanced: Compare values
if %ERRORLEVEL%==0 echo Successfor Loops through values.
:: Basic: List .txt files
for %f in (*.txt) do echo %f
:: Advanced: Process files in script
for /R %%f in (*.txt) do copy %%f D:\Backupgoto Jumps to labeled line.
:: Basic: Jump to end
goto :end
:end
echo Done
:: Advanced: Conditional jump
if %ERRORLEVEL%==1 goto :error
:error
echo Failedcall Calls another script/function.
:: Basic: Call script
call myscript.bat
:: Advanced: Call subroutine
call :subroutine
:subroutine
echo Subroutinesetlocal / endlocal Manages variable scope.
:: Basic: Local variable
setlocal
set MYVAR=123
endlocal
:: Advanced: Preserve variable
setlocal EnableDelayedExpansion
set MYVAR=!DATE!
endlocal & set GLOBALVAR=%MYVAR%Bonus Useful Commands
clip Redirects to clipboard.
:: Basic: Copy dir output
dir | clip
:: Advanced: Copy system info
systeminfo | clipfind Searches text in files.
:: Basic: Find text
find "error" log.txt
:: Advanced: Case-sensitive search
find /i "error" log.txtassoc Manages file associations.
:: Basic: Show .txt association
assoc .txt
:: Advanced: Set association
assoc .txt=txtfiledriverquery Lists installed drivers.
:: Basic: List drivers
driverquery
:: Advanced: Export to CSV
driverquery /fo csv > drivers.csvtaskview Opens Task View.
:: Basic: Launch Task View
explorer.exe shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257}
:: Advanced: Scripted launch
echo Opening Task View... & explorer.exe shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257}Last updated