Hidden CMD Commands That Can Fix Your Windows OS Instantly
File & Directory Management
- dir
– Lists files and folders in the current directory
- cd
– Changes the current directory
- cd..
– Moves up one directory level
- md
– Creates a new directory
- mkdir
– Same as md, creates a folder
- rd
– Removes an empty directory
- rmdir
– Deletes a directory
- del
– Deletes files
- erase
– Same as del, removes files
- copy
– Copies files from one location to another
- xcopy
– Copies files and directories (advanced)
- robocopy
– Robust file copy tool with advanced options
- move
– Moves files or folders
- rename
– Renames a file or folder
- ren
– Same as rename
- type
– Displays contents of a text file
- more
– Displays output one screen at a time
- fc
– Compares two files
- attrib
– Displays or changes file attributes
- tree
– Shows directory structure graphically
Disk Management
- chkdsk
– Checks disk for errors
- diskpart
– Opens disk partition tool
- format
– Formats a disk
- vol
– Displays disk volume label and serial
- label
– Creates or changes volume label
- defrag
– Defragments a disk
- fsutil
– Performs advanced file system tasks
- mountvol
– Manages volume mount points
- recover
– Recovers readable data from disk
- subst – Maps a path to a drive letter
System Information
- systeminfo
– Displays system configuration info
- hostname
– Shows computer name
- ver
– Displays Windows version
- set
– Displays environment variables
- echo
– Prints messages to screen
- time
– Displays or sets system time
- date
– Displays or sets system date
- cls
– Clears the screen
- title
– Sets window title
- path
– Displays or sets executable search path
Process Management
- tasklist
– Lists running processes
- taskkill
– Terminates a process
- start
– Opens a program or file
- shutdown
– Shuts down or restarts computer
- logoff
– Logs off current user
- exit
– Closes command prompt
- timeout
– Waits for a specified time
- pause
– Pauses execution until key press
- call
– Calls another batch file
- cmd
– Starts a new command shell
Networking
- ipconfig
– Displays IP configuration
- ipconfig
/all – Shows detailed network info
- ping
– Tests network connectivity
- tracert
– Traces route to a host
- netstat
– Displays network connections
- nslookup
– Queries DNS records
- arp
– Displays ARP table
- route
– Displays/modifies routing table
- getmac
– Shows MAC address
- net
– Manages network resources
User & Permissions
- whoami
– Displays current user
- net
user – Manages user accounts
- net
localgroup – Manages local groups
- runas
– Runs a program as another user
- icacls
– Modifies file permissions
- cacls
– Displays/modifies ACLs (older)
- takeown
– Takes ownership of files
- gpupdate
– Updates group policies
- gpresult
– Displays group policy results
- net
accounts – Displays account policies
Batch & Scripting
- setlocal
– Starts local environment for batch
- endlocal
– Ends local environment
- for
– Runs loop commands
- if
– Conditional execution
- goto
– Jumps to label in script
- shift
– Shifts parameters in batch file
- exit
/b – Exits batch file
- rem
– Adds comments in scripts
- ::
– Another way to comment
- choice
– Prompts user for input
File Viewing &
Search
- find
– Searches for text in files
- findstr
– Advanced text search
- sort
– Sorts input data
- clip
– Copies output to clipboard
- more
– Displays output page by page
- type
– Displays file content
- assoc
– Displays file associations
- ftype
– Displays file type associations
- where
– Locates files in path
- comp
– Compares file contents
Miscellaneous
- help
– Lists available commands
- color
– Changes CMD text color
- prompt
– Changes command prompt style
- doskey
– Edits command history
- cls
– Clears screen
- exit
– Closes CMD
- mode
– Configures system devices
- print
– Prints text file
- verify
– Checks file write success
- title – Sets CMD window title
Advanced File & Directory Operations
- pushd
– Saves current directory and changes to a new one
- popd
– Returns to the previous directory
- dir
/s – Lists files in all subdirectories
- dir
/a – Shows hidden/system files
- dir
/o – Sorts directory listing
- copy
con – Creates a file from keyboard input
- replace
– Replaces files in directories
- move
/y – Moves files without confirmation
- del
/f – Forces deletion of read-only files
- attrib
+h – Hides a file
Disk & Storage
Advanced
- diskcomp
– Compares two floppy disks
- diskcopy
– Copies floppy disk to another
- format
/q – Quick formats a disk
- chkdsk
/f – Fixes disk errors
- chkdsk
/r – Locates bad sectors
- fsutil
volume diskfree – Shows disk free space
- fsutil
fsinfo drives – Lists all drives
- mountvol
/l – Lists volume GUIDs
- label
/mp – Labels mounted volume
- defrag
/a – Analyzes fragmentation
System &
Performance
- powercfg
– Manages power settings
- powercfg
/energy – Generates energy report
- perfmon
– Opens Performance Monitor
- resmon
– Opens Resource Monitor
- taskmgr
– Opens Task Manager
- msinfo32
– Opens system info GUI
- winver
– Shows Windows version window
- driverquery
– Lists installed drivers
- driverquery
/v – Detailed driver info
- logman
– Manages performance logs
Networking Advanced
- net
use – Connects to shared resources
- net
view – Displays network computers
- net
share – Manages shared resources
- net
session – Lists active sessions
- net
file – Displays open shared files
- netstat
-a – Shows all connections
- netstat
-b – Shows executable per connection
- netstat
-o – Displays process IDs
- nbtstat
– Displays NetBIOS stats
- pathping
– Combines ping and tracert
Security &
Permissions
- cipher
– Manages file encryption
- cipher
/e – Encrypts files
- cipher
/d – Decrypts files
- auditpol
– Manages audit policies
- secedit
– Configures security settings
- whoami
/priv – Shows user privileges
- whoami
/groups – Lists user groups
- net
user /add – Adds new user
- net
user /delete – Deletes user
- net
localgroup /add – Adds group
Services Management
- sc
– Manages services
- sc
query – Displays service status
- sc
start – Starts a service
- sc
stop – Stops a service
- sc
config – Changes service settings
- net
start – Starts services
- net
stop – Stops services
- tasklist
/svc – Shows services in processes
- wmic
service list – Lists services
- wmic
service get name – Gets service names
Windows Management
Instrumentation (WMI)
- wmic
– Opens WMI interface
- wmic
cpu get name – Shows CPU info
- wmic
os get caption – Shows OS name
- wmic
diskdrive list – Lists drives
- wmic
bios get serialnumber – Gets BIOS serial
- wmic
memorychip – Displays RAM info
- wmic
process list – Lists processes
- wmic
logicaldisk – Lists logical disks
- wmic
startup – Shows startup programs
- wmic
useraccount – Lists user accounts
Registry Operations
- reg
query – Queries registry
- reg
add – Adds registry entry
- reg
delete – Deletes registry key
- reg
export – Exports registry
- reg
import – Imports registry
- reg
copy – Copies registry key
- reg
save – Saves registry
- reg
load – Loads registry hive
- reg
unload – Unloads registry hive
- reg
compare – Compares registry entries
Boot & Recovery
- bcdedit
– Manages boot configuration
- bootrec
– Repairs boot issues
- bootsect
– Updates boot sector
- shutdown
/r – Restarts system
- shutdown
/s – Shuts down system
- shutdown
/l – Logs off user
- reagentc
– Manages recovery environment
- sfc
– System file checker
- sfc
/scannow – Scans and repairs system files
- dism
– Repairs Windows image
Misc Advanced Commands
- assoc
.txt – Shows file association
- ftype
txtfile – Shows file type command
- clip
< file.txt – Copies file content
- hostname
> file.txt – Saves output to file
- setx
– Sets environment variable permanently
- echo
%cd% – Displays current directory
- color
0a – Changes CMD color (green text)
- title
MyCMD – Sets custom window title
- mode
con cols=80 – Sets window width
- exit /b 0 – Exits script with code
Advanced Networking & Troubleshooting
- ipconfig
/release – Releases current IP address
- ipconfig
/renew – Renews IP address
- ipconfig
/flushdns – Clears DNS cache
- ipconfig
/displaydns – Shows DNS cache
- ipconfig
/registerdns – Refreshes DHCP & DNS
- netsh
– Opens network shell tool
- netsh
wlan show profiles – Lists saved Wi-Fi profiles
- netsh
wlan show profile name="WiFi" – Shows Wi-Fi details
- netsh
wlan export profile – Exports Wi-Fi config
- netsh
int ip reset – Resets TCP/IP stack
- netsh
winsock reset – Resets Winsock catalog
- netsh
advfirewall show allprofiles – Shows firewall status
- netsh
advfirewall reset – Resets firewall settings
- netsh
interface show interface – Lists network interfaces
- netsh
interface ip show config – Shows IP configuration
- netsh
interface ip set address – Sets static IP
- netsh
interface ip set dns – Sets DNS server
- route
print – Displays routing table
- route
add – Adds route
- route
delete – Deletes route
Remote Access &
System Control
- mstsc
– Opens Remote Desktop
- qwinsta
– Lists remote sessions
- rwinsta
– Resets session
- logoff
<id> – Logs off remote session
- shutdown
/m \\computer – Remote shutdown
- shutdown
/r /m \\computer – Remote restart
- psexec
– Executes commands remotely (Sysinternals)
- winrm
– Windows Remote Management
- winrm
quickconfig – Enables WinRM
- query
user – Lists logged-in users
Advanced Process &
Performance
- taskkill
/f – Forces process termination
- tasklist
/fi – Filters processes
- start
/affinity – Runs program on specific CPU
- wmic
process where name="app.exe" – Finds process
- wmic
process call terminate – Kills process via WMI
- typeperf
– Displays performance counters
- logman
start – Starts logging session
- logman
stop – Stops logging
- lodctr
– Updates performance counters
- relog
– Converts performance logs
File System &
Permissions (Advanced)
- icacls
/grant – Grants file permissions
- icacls
/deny – Denies permissions
- icacls
/remove – Removes permissions
- takeown
/f – Takes ownership
- attrib
-h -r -s – Removes hidden/system/read-only
- compact
– Compresses files
- compact
/c – Compress file
- compact
/u – Uncompress file
- cipher
/w – Wipes free space
- fsutil
file createnew – Creates empty file
Disk & Volume Deep
Tools
- diskpart
list disk – Lists disks
- diskpart
select disk – Selects disk
- diskpart
clean – Removes partitions
- diskpart
create partition primary – Creates partition
- diskpart
format fs=ntfs – Formats partition
- diskpart
assign – Assigns drive letter
- diskpart
active – Marks partition active
- mountvol
/p – Removes mount point
- chkdsk
/x – Forces volume dismount
- defrag
/x – Consolidates free space
System Repair &
Maintenance
- sfc
/verifyonly – Verifies system files
- dism
/online /cleanup-image /scanhealth – Checks image health
- dism
/online /cleanup-image /restorehealth – Repairs image
- cleanmgr
– Disk cleanup tool
- cleanmgr
/sageset – Configure cleanup options
- cleanmgr
/sagerun – Run configured cleanup
- powercfg
/batteryreport – Generates battery report
- powercfg
/sleepstudy – Sleep analysis report
- wevtutil
qe – Queries event logs
- wevtutil
cl – Clears event logs
Event Logs &
Monitoring
- eventvwr
– Opens Event Viewer
- wevtutil
el – Lists event logs
- wevtutil
gl – Gets log configuration
- wevtutil
sl – Sets log properties
- logman
query – Lists data collectors
- perfmon
/report – Generates performance report
- typeperf
"\Processor(_Total)\% Processor Time" – CPU usage
- resmon
/cpu – CPU resource monitor
- resmon
/memory – Memory monitor
- resmon
/disk – Disk monitor
Advanced Networking
& Security
- net
accounts /lockoutthreshold – Sets lockout policy
- netsh
firewall show state – Shows firewall state (legacy)
- netsh
advfirewall firewall add rule – Adds firewall rule
- netsh
advfirewall firewall delete rule – Deletes rule
- netstat
-e – Displays Ethernet stats
- netstat
-r – Displays routing table
- netstat
-s – Displays protocol stats
- arp
-a – Displays ARP entries
- nbtstat
-n – Shows NetBIOS names
- nbtstat
-c – Shows NetBIOS cache
Environment &
Advanced Scripting
- set
/p – Takes user input in script
- set
/a – Performs arithmetic operations
- for
/f – Parses command output
- if
exist – Checks file existence
- if
errorlevel – Checks exit codes
- call
:label – Calls subroutine
- exit
/b 1 – Returns error code
- cmd
/c – Runs command and exits
- cmd
/k – Runs command and stays open
- powershell – Launches PowerShell from CMD
Rare & Legacy File Commands
- append
– Allows programs to open files in specified directories
- expand
– Extracts compressed files (.cab)
- extrac32
– Extracts CAB files (older tool)
- makecab
– Creates CAB compressed files
- lodctr
/r – Rebuilds performance counters
- unlodctr
– Removes performance counters
- sort
/r – Sorts in reverse order
- find
/v – Displays lines not containing text
- fc
/b – Compares files in binary mode
- comp
/a – Compares files ASCII
Hidden System Utilities
- sigverif
– Verifies file signatures
- verifier
– Driver Verifier tool
- dxdiag
– DirectX diagnostic tool
- mrt
– Malicious Software Removal Tool
- wiaacmgr
– Scanner and camera wizard
- shrpubw
– Shared folder wizard
- fsmgmt.msc
– Shared folders manager
- compmgmt.msc
– Computer management
- devmgmt.msc
– Device manager
- diskmgmt.msc
– Disk management
Legacy Networking Tools
- netsh
diag show all – Displays diagnostics (deprecated)
- netsh
ras show – Shows remote access info
- rasdial
– Connects/disconnects dial-up/VPN
- rasphone
– Opens dial-up networking
- netsh
bridge show adapter – Shows bridge config
- netsh
lan show interfaces – Shows LAN interfaces
- netsh
wlan delete profile – Deletes Wi-Fi profile
- getmac
/v – Detailed MAC info
- arp
-d – Deletes ARP entry
- pathping
/n – No DNS resolution
Advanced Boot &
Recovery (Rare)
- bootrec
/fixmbr – Repairs Master Boot Record
- bootrec
/fixboot – Writes new boot sector
- bootrec
/scanos – Scans for OS installations
- bootrec
/rebuildbcd – Rebuilds boot config
- bcdedit
/enum all – Lists all boot entries
- bcdboot
– Repairs boot files
- reagentc
/info – Shows recovery info
- reagentc
/enable – Enables recovery
- reagentc
/disable – Disables recovery
- shutdown
/fw – Boots into firmware (BIOS/UEFI)
Deep System Internals
- wmic
qfe list – Lists installed updates
- wmic
baseboard get product – Shows motherboard info
- wmic
nic list – Lists network adapters
- wmic
environment list – Shows environment variables
- wmic
timezone – Displays timezone info
- wmic
pagefile list – Shows pagefile settings
- wmic
recoveros – Displays recovery config
- wmic
cpu get loadpercentage – CPU load
- wmic
os get lastbootuptime – Last boot time
- wmic
diskquota list – Disk quota info
Rare Disk & File
System Tools
- chkntfs
– Displays NTFS check status
- chkntfs
/x – Excludes drive from check
- fsutil
dirty query – Checks dirty bit
- fsutil
dirty set – Marks volume dirty
- fsutil
behavior query – Shows FS behavior
- fsutil
usn – Manages update sequence number
- fsutil
quota – Manages disk quotas
- mountvol
/r – Removes stale mount points
- recover
/a – Recovers all readable data
- subst
/d – Deletes virtual drive
Rare Security &
Encryption
- cipher
/k – Creates encryption key
- cipher
/x – Backs up encryption cert
- runas
/savecred – Saves credentials (use carefully)
- whoami
/all – Full user info
- net
user /expires – Sets account expiration
- net
accounts /maxpwage – Password max age
- auditpol
/get – Shows audit policies
- auditpol
/set – Sets audit policy
- secedit
/export – Exports security config
- secedit
/configure – Applies security template
Event & Logging
Hidden Gems
- wevtutil
epl – Exports event logs
- wevtutil
im – Installs manifest
- wevtutil
um – Uninstalls manifest
- logman
create counter – Creates performance counter
- logman
delete – Deletes data collector
- relog
/q – Queries log files
- typeperf
-qx – Lists counters
- perfmon
/sys – System monitor
- eventcreate
– Creates custom event
- eventtriggers
– Configures event triggers (legacy)
CMD Environment Tricks
- %cd%
– Current directory variable
- %random%
– Random number generator
- %errorlevel%
– Last command status
- %date%
– Current date
- %time%
– Current time
- set
var=value – Creates variable
- echo
%var% – Displays variable
- setx
var value – Permanent variable
- for
%i in (*) do echo %i – Loops files
- call
%var% – Executes variable as command
Hidden CMD Features
& Tricks
- doskey
/history – Shows command history
- doskey
/reinstall – Reinstalls macros
- prompt
$p$g – Default prompt format
- prompt
$t – Shows time in prompt
- color
/? – Lists color options
- cls
&& echo Done – Chain commands
- dir
| find "txt" – Pipe output
- echo
Hello > file.txt – Write to file
- echo
Hello >> file.txt – Append to file
- start . – Opens current folder in Explorer
Expert Debugging & Diagnostics
- dbghelp
– Debugging helper tools (library support)
- drwtsn32
– Dr. Watson debugger (legacy crash tool)
- ntsd
– NT symbolic debugger
- cdb
– Console debugger (advanced)
- kd
– Kernel debugger
- windbg
– GUI debugger (external tool)
- gflags
– Enables advanced debugging flags
- sxstrace
– Traces side-by-side errors
- werfault
– Windows Error Reporting tool
- procdump
– Captures process dumps (Sysinternals)
Advanced System
Internals
- handle
– Lists open file handles (Sysinternals)
- procexp
– Process Explorer tool
- autoruns
– Shows startup programs (Sysinternals)
- vmmap
– Displays virtual memory usage
- rammap
– Analyzes RAM usage
- coreinfo
– CPU/core details (Sysinternals)
- pslist
– Lists processes remotely
- pskill
– Kills remote processes
- psinfo
– System info (Sysinternals)
- psloggedon
– Shows logged-in users
Advanced Networking
(Deep Analysis)
- netsh
trace start – Starts network trace
- netsh
trace stop – Stops trace
- pktmon
start – Starts packet monitoring
- pktmon
stop – Stops packet monitoring
- pktmon
format – Formats packet logs
- netsh
http show servicestate – HTTP.sys status
- netsh
winhttp show proxy – Shows proxy config
- netsh
winhttp reset proxy – Resets proxy
- netstat
-x – Shows NetworkDirect connections
- netstat
-y – Shows TCP templates
Advanced Security &
Forensics
- auditpol
/backup – Backs up audit policies
- auditpol
/restore – Restores audit policies
- cipher
/c – Displays encryption info
- certutil
– Manages certificates
- certutil
-store – Lists certificates
- certutil
-verify – Verifies certificate
- klist
– Lists Kerberos tickets
- klist
purge – Clears Kerberos tickets
- whoami
/claims – Shows claims-based identity
- runas
/netonly – Runs with network credentials
Advanced Disk &
Storage (Low-Level)
- diskshadow
– Volume Shadow Copy tool
- vssadmin
list shadows – Lists shadow copies
- vssadmin
delete shadows – Deletes shadow copies
- wbadmin
start backup – Starts backup
- wbadmin
get versions – Lists backup versions
- wbadmin
start recovery – Restores backup
- fsutil
repair query – Shows repair status
- fsutil
repair set – Configures repair
- chkdsk
/scan – Online scan
- chkdsk
/spotfix – Fast repair
Advanced Boot &
System Recovery
- bcdedit
/set – Modifies boot settings
- bcdedit
/delete – Removes boot entry
- bootsect
/nt60 – Updates boot code
- bootsect
/nt52 – Legacy boot code
- reagentc
/boottore – Boots to recovery
- shutdown
/o – Opens advanced boot menu
- shutdown
/hybrid – Hybrid shutdown
- shutdown
/soft – Soft shutdown
- systemreset
– Resets Windows
- reset
– Resets CMD environment
Rare Windows Utilities
- at
– Schedules tasks (deprecated)
- schtasks
– Schedules tasks (modern)
- schtasks
/query – Lists scheduled tasks
- schtasks
/create – Creates task
- schtasks
/delete – Deletes task
- lodctr
/q – Queries performance counters
- unlodctr
/q – Queries removed counters
- timeout
/t -1 – Waits indefinitely
- waitfor
– Synchronizes processes
- openfiles
– Displays open files
CMD Internals &
Power Features
- cmd
/q – Turns echo off
- cmd
/v – Enables delayed expansion
- setlocal
enabledelayedexpansion – Enables dynamic variables
- endlocal
& set var=value – Exports variable
- for
/l – Loop with numbers
- for
/r – Loop directories recursively
- for
/d – Loop directories only
- if
defined var – Checks variable existence
- set
/a x+=1 – Increment variable
- call
echo %%var%% – Expands delayed variable
Hidden & Rare Gems
- assoc
| find – Filters associations
- ftype
| more – Lists file types paginated
- color
1f – Blue background, bright white text
- prompt
$d $t – Shows date and time
- echo
^G – Beep sound
- cls
& dir – Clears and lists files
- dir
/x – Shows short filenames
- dir
/q – Shows file owner
- dir
/r – Shows alternate data streams
- more
< file.txt – Reads file page-wise
Extreme / Internal /
Rarely Used
- subst
z: c:\path – Creates virtual drive
- subst
z: /d – Removes virtual drive
- verify
on – Verifies file writes
- verify
off – Disables verification
- break
– Sets Ctrl+C behavior
- exit
/b %errorlevel% – Returns last error
- cmd
/a – ANSI output mode
- cmd
/u – Unicode output mode
- start
"" cmd /k – Opens new persistent CMD
- echo %cmdcmdline% – Shows full CMD command line

Comments
Post a Comment