π₯οΈ All Essential Windows CMD Commands for Diagnostics, Repair & System Management
π Published: October 29, 2026
The Command Prompt (CMD) is one of the oldest and most important tools in Windows for running commands, diagnosing the system, fixing certain failures, and managing files, networking, processes, and services. Although Microsoft recommends PowerShell for modern automation, CMD commands remain extremely useful for daily diagnostics and maintenance. [1]
This guide collects the most important CMD commands that Windows users and support technicians need, with explanations and ready-to-copy examples.
β οΈ Before you begin:
- Run system-changing commands with care
- Some commands require opening CMD as Administrator
- Some may delete files, terminate programs, disconnect the network, or modify disk settings
- Back up your data before advanced repair commands
- Never run a command whose effect you don’t understand
π Table of Contents
| # | Section | Main Commands |
|---|---|---|
| 1 | π Opening CMD | Correct methods |
| 2 | π Important rules | Tips before running |
| 3 | π Files & navigation | dir cd copy robocopy |
| 4 | βΉοΈ System info | systeminfo dxdiag msinfo32 |
| 5 | π§ System repair | DISM sfc |
| 6 | πΎ Disk diagnostics | chkdsk chkntfs |
| 7 | π Network diagnostics | ipconfig ping nslookup |
| 8 | βοΈ Processes & apps | tasklist taskkill |
| 9 | π Services | sc net start |
| 10 | π Power & battery | powercfg |
| 11 | π Shutdown/Restart | shutdown |
| 12 | π€ Users & permissions | net user net localgroup |
| 13 | π Logs & scheduled tasks | wevtutil schtasks |
| 14 | π½ Disks (danger) | diskpart format |
| 15 | π Permissions | icacls takeown |
| 16 | π― By problem | Quick fixes |
| 17 | π« Dangerous commands | Avoid |
π How to Open CMD as Administrator
Method 1: From the Start Menu
| Step | Action |
|---|---|
| 1οΈβ£ | Open the Start menu |
| 2οΈβ£ | Type cmd or Command Prompt |
| 3οΈβ£ | Right-click Command Prompt |
| 4οΈβ£ | Choose Run as administrator |
| 5οΈβ£ | Approve the User Account Control prompt |
Method 2: Keyboard shortcut
Press Win + R and type:
cmd
π‘ Tip: To request admin rights from the Run dialog, press
Ctrl + Shift + Enterafter typingcmd.
How do you know CMD is running as Administrator?
| Indicator | Description |
|---|---|
| π·οΈ Window title | Shows Administrator: Command Prompt |
| β οΈ Commands | sfc, DISM, chkdsk /f fail without it |
π Important Rules Before Using CMD
π― Six golden rules
| # | Rule | Example |
|---|---|---|
| 1οΈβ£ | Use /? for help |
ipconfig /? |
| 2οΈβ£ | Quote paths with spaces | cd /d "C:\Program Files" |
| 3οΈβ£ | Use Tab for autocomplete |
Type C:\Pro then Tab |
| 4οΈβ£ | Save output to a file | systeminfo > report.txt |
| 5οΈβ£ | Use | more for long output |
tasklist | more |
| 6οΈβ£ | Stop a running command with Ctrl + C |
For ping -t |
π File & Navigation Commands
Full command table
| Command | Purpose | Example |
|---|---|---|
cls |
Clear screen | cls |
echo |
Print text | echo Hello |
ver |
Windows version | ver |
hostname |
Computer name | hostname |
whoami |
Current user | whoami /all |
cd |
Change directory | cd C:\Users |
dir |
List files | dir /a /s |
tree |
Folder tree | tree C:\ /f |
mkdir |
Create folder | mkdir C:\Temp |
rmdir |
Delete folder | rmdir /s C:\Old |
copy |
Copy files | copy report.txt D:\ |
xcopy |
Extended copy | xcopy C:\A D:\B /E /I |
robocopy |
Advanced copy | robocopy C:\A D:\B /E /Z |
move |
Move files | move file.txt D:\ |
del |
Delete files | del old.txt |
ren |
Rename file | ren old.txt new.txt |
type |
Display file | type notes.txt |
findstr |
Search output | tasklist | findstr chrome |
attrib |
File attributes | attrib +r file.txt |
fc |
Compare files | fc /n a.txt b.txt |
clip |
Copy to clipboard | ipconfig | clip |
where |
Locate executable | where notepad |
ποΈ Folder command details
cd β Navigate between folders
cd C:\Users :: Go to a folder
cd .. :: Parent folder
cd \ :: Drive root
cd /d D:\Backup :: Change drive and folder
dir β List files
| Option | Function |
|---|---|
/a |
Show hidden and system files |
/s |
Search subfolders |
/b |
Bare names only |
/o:-d |
Sort by date (descending) |
robocopy β Professional backup
robocopy "C:\Source" "D:\Backup" /E /Z /R:2 /W:5 /LOG:"D:\backup.log"
| Option | Description |
|---|---|
/E |
Copy subfolders (including empty) |
/Z |
Resume after interruption |
/R:2 |
Retry twice |
/W:5 |
Wait 5 seconds between retries |
/LOG: |
Save a report |
π¨ Warning about
/MIR: This option mirrors source to destination, and may delete files in the destination that don’t exist in the source. Test with/L(simulation) first:robocopy "C:\Source" "D:\Destination" /MIR /L
βΉοΈ System Information Commands
System info command table
| Command | Purpose | Best for |
|---|---|---|
systeminfo |
Windows & hardware info | Full report |
set |
Environment variables | Diagnosing PATH |
setx |
Create persistent variable | App setup |
driverquery |
List drivers | Driver review |
msinfo32 |
System Information tool | Hardware review |
dxdiag |
DirectX diagnostics | Graphics issues |
winsat |
Performance benchmark | Speed testing |
π Details
systeminfo β Full report
systeminfo
systeminfo /fo list
systeminfo > "%USERPROFILE%\Desktop\systeminfo.txt"
π‘ Use when you need: Windows version, install date, RAM, hardware info, network status β in one report.
driverquery β Driver list
driverquery
driverquery /fo csv > drivers.csv
π Note: This shows loaded drivers but does not prove every driver is up to date or healthy.
dxdiag β DirectX Diagnostic Tool
dxdiag
Opens the DirectX Diagnostic Tool β useful for graphics, audio, and gaming issues.
π§ Windows System Repair Commands
π― Correct repair order
ββββββββββββββββββββββββββββββ
β 1. Backup π¦ β
βββββββββββββββ¬βββββββββββββββ
β
ββββββββββββββββββββββββββββββ
β 2. Open CMD as Admin π‘οΈ β
βββββββββββββββ¬βββββββββββββββ
β
ββββββββββββββββββββββββββββββ
β 3. DISM /RestoreHealth π§ β
βββββββββββββββ¬βββββββββββββββ
β
ββββββββββββββββββββββββββββββ
β 4. SFC /scannow π©Ί β
βββββββββββββββ¬βββββββββββββββ
β
ββββββββββββββββββββββββββββββ
β 5. Restart π β
ββββββββββββββββββββββββββββββ
DISM & SFC command table
| Command | Purpose | Duration |
|---|---|---|
DISM /CheckHealth |
Quick corruption check | Seconds |
DISM /ScanHealth |
Deeper scan | Minutes |
DISM /RestoreHealth |
Repair Windows image | 10β30 min |
sfc /scannow |
Scan & repair system files | 5β15 min |
sfc /verifyonly |
Scan without repair | 5β10 min |
π Full commands
DISM /RestoreHealth β Repair Windows image
DISM /Online /Cleanup-Image /RestoreHealth
β±οΈ Warning: Do not close the CMD window during DISM, even if the progress seems stuck for a while.
sfc /scannow β Scan system files
sfc /scannow
π What SFC results mean
| Result | Meaning |
|---|---|
| β did not find any integrity violations | No corruption found |
| π§ found corrupt files and successfully repaired them | Found and repaired |
| β οΈ found corrupt files but was unable to fix some | Run DISM, then SFC |
| β could not perform the requested operation | Permissions or disk issue |
πΎ Disk Diagnostic Commands
Disk command table
| Command | Purpose | Admin? | Duration |
|---|---|---|---|
chkdsk C: |
Show status | β | Seconds |
chkdsk C: /scan |
Online scan | β | Minutes |
chkdsk C: /f |
Fix file system errors | β | 10β30 min |
chkdsk C: /r |
Scan sectors | β | Hours |
chkntfs C: |
Auto-check status | β | Seconds |
fsutil dirty query C: |
Is volume flagged? | β | Seconds |
π chkdsk details
chkdsk C: :: Show status
chkdsk C: /scan :: Scan without repair
chkdsk C: /f :: Fix file system errors
chkdsk C: /r :: Scan bad sectors (includes /f)
π¨ Critical warning:
- If the disk makes abnormal noises β back up data first
chkdskrepairs file system structure but does not fix a dying disk/rmay take hours on large disks
π‘ Info: Microsoft states that
/rincludes/ffunctionality and adds a physical error scan. [6]
π Network Diagnostic Commands
Full networking command table
| Command | Purpose | Example |
|---|---|---|
ipconfig |
Show IP settings | ipconfig /all |
ipconfig /release |
Release IP | ipconfig /release |
ipconfig /renew |
Renew IP | ipconfig /renew |
ipconfig /flushdns |
Clear DNS | ipconfig /flushdns |
ipconfig /displaydns |
Show DNS cache | ipconfig /displaydns |
ping |
Test connectivity | ping 8.8.8.8 |
tracert |
Trace route | tracert example.com |
pathping |
Analyze packet loss | pathping example.com |
nslookup |
DNS diagnostics | nslookup example.com |
netstat |
Connections & ports | netstat -ano |
arp |
ARP cache | arp -a |
route print |
Routing table | route print |
netsh |
Network management | netsh wlan show profiles |
π©Ί Internet troubleshooting β step by step
π― Diagnostic sequence
| # | Command | Goal |
|---|---|---|
| 1οΈβ£ | ipconfig /all |
Confirm IP exists |
| 2οΈβ£ | ping 127.0.0.1 |
Test local TCP/IP |
| 3οΈβ£ | ping 192.168.1.1 |
Test router |
| 4οΈβ£ | ping 8.8.8.8 |
Test internet |
| 5οΈβ£ | ping example.com |
Test DNS |
| 6οΈβ£ | nslookup example.com |
Diagnose DNS |
| 7οΈβ£ | ipconfig /flushdns |
Clear DNS cache |
π Interpreting results
| Result | Diagnosis |
|---|---|
β
127.0.0.1 works + 8.8.8.8 works + example.com fails |
π DNS issue |
β
8.8.8.8 works + example.com fails |
π DNS issue |
β Both 8.8.8.8 and example.com fail |
π Router or ISP issue |
β 127.0.0.1 fails |
π TCP/IP stack issue |
π Main command details
ipconfig β Subcommands
ipconfig :: Basic info
ipconfig /all :: Full details
ipconfig /release :: Release IP
ipconfig /renew :: Renew IP
ipconfig /flushdns :: Clear DNS
ipconfig /displaydns :: Show DNS cache
β οΈ Warning:
ipconfig /releasemay briefly disconnect you. Don’t use it on a remote machine you need to stay connected to.
ping β Test connectivity
ping 8.8.8.8 :: Default count
ping -n 10 example.com :: 10 requests
ping -t 192.168.1.1 :: Continuous (Ctrl+C to stop)
π‘ Info: Microsoft explains that
pingsends ICMP requests and shows the reply and round-trip time. [3]
nslookup β DNS diagnostics
nslookup example.com
nslookup example.com 8.8.8.8 :: Query a specific DNS
nslookup -type=MX example.com :: Query MX records
netstat β Connections & ports
netstat -ano :: All + PID
netstat -abno :: + program
netstat -r :: Routing table
netstat -ano 5 :: Every 5 seconds
| Option | Function |
|---|---|
-a |
All connections and listening ports |
-n |
Numbers only (no name resolution) |
-o |
Owning process PID |
-b |
Executable name |
-r |
Routing table |
netsh β Network management
netsh interface show interface :: List interfaces
netsh interface ip show config :: IP settings
netsh wlan show wlanreport :: WLAN report
netsh wlan show profiles :: Saved Wi-Fi profiles
netsh winsock reset :: Reset Winsock
netsh int ip reset :: Reset TCP/IP
π Privacy note:
netsh wlan show profile name="SSID" key=clearmay reveal a saved network password. Don’t use it on a device you don’t own.
βοΈ Process & Application Management Commands
Process command table
| Command | Purpose | Example |
|---|---|---|
tasklist |
List processes | tasklist /v |
taskkill |
Terminate a process | taskkill /im notepad.exe |
start |
Launch a program | start notepad |
π Details
tasklist β List processes
tasklist :: Basic list
tasklist /v :: Details
tasklist /svc :: Associated services
tasklist /fi "STATUS eq NOT RESPONDING" :: Hung processes
tasklist /fo csv > processes.csv :: Save as CSV
taskkill β Terminate a process
taskkill /pid 1234 :: By PID
taskkill /im notepad.exe :: By name
taskkill /f /im notepad.exe :: Force
taskkill /f /t /pid 1234 :: + child processes
π¨ Critical warning:
/fforces termination β unsaved data loss- Never use
taskkill /f /im *β may close system processes
π‘ Info: Microsoft warns that
/fforcibly ends a process. [14]
π Service Management Commands
Service command table
| Command | Purpose | Example |
|---|---|---|
sc query |
Show service state | sc query wuauserv |
sc start |
Start service | sc start Spooler |
sc stop |
Stop service | sc stop Spooler |
net start |
List/start | net start |
net stop |
Stop service | net stop Spooler |
β οΈ Warning: Randomly stopping Windows services may break updates, printing, or networking. Never stop a service before understanding its role.
π Power & Battery Commands
powercfg command table
| Command | Purpose | Duration |
|---|---|---|
powercfg /batteryreport |
Battery report | Seconds |
powercfg /energy |
Power analysis | 60 seconds |
powercfg /requests |
What blocks sleep | Seconds |
powercfg /lastwake |
Last wake reason | Seconds |
powercfg /a |
Available sleep states | Seconds |
powercfg /hibernate on |
Enable Hibernate | Seconds |
π Details
powercfg /batteryreport β Battery report
powercfg /batteryreport /output "%USERPROFILE%\Desktop\battery-report.html"
Generates an HTML report covering:
- π Original vs. current battery capacity
- π Battery usage history
- β±οΈ Estimated battery life
powercfg /energy β Power efficiency analysis
powercfg /energy /output "%USERPROFILE%\Desktop\energy-report.html" /duration 60
π‘ Tip: Close unnecessary programs and leave the device idle before running.
powercfg /requests β What blocks sleep?
powercfg /requests
Shows programs or drivers that prevent the screen from turning off or the device from sleeping.
π Shutdown & Restart Commands
shutdown command table
| Command | Purpose |
|---|---|
shutdown /s /t 0 |
Shut down now |
shutdown /r /t 0 |
Restart now |
shutdown /r /t 60 |
Restart in 60 seconds |
shutdown /a |
Cancel scheduled shutdown |
shutdown /l |
Log off |
shutdown /r /o /t 0 |
Advanced boot options |
shutdown /r /t 60 /c "Scheduled restart for maintenance"
β οΈ Warning:
/fforces applications to close without warning. Use only when necessary. [16]
π€ User & Permission Commands
User command table
| Command | Purpose | Example |
|---|---|---|
net user |
List users | net user |
net user username |
User details | net user john |
net user NewUser * /add |
Create user | β |
net localgroup |
Local groups | net localgroup |
net localgroup administrators |
Admin members | β |
gpupdate /force |
Update policies | β |
gpresult /r |
Show applied policies | β |
π Security warning:
- Don’t create admin accounts on machines you don’t own
- Avoid putting passwords directly in the command
- Adding a user to Administrators grants broad privileges
π Logs & Scheduled Tasks Commands
Log command table
| Command | Purpose | Example |
|---|---|---|
schtasks /query |
List tasks | schtasks /query /fo LIST /v |
wevtutil el |
List logs | wevtutil el |
wevtutil qe System |
System events | wevtutil qe System /c:20 |
wevtutil qe Application |
Application events | wevtutil qe Application /c:20 |
schtasks /query /fo CSV > scheduled-tasks.csv
wevtutil qe System /c:20 /rd:true /f:text
π‘ Tip: Event logs help identify why a service, driver, or application crashed. Don’t delete logs just because old errors exist.
π½ Disk Commands: Special Warning
π¨ Danger zone
| Command | Risk | Safe use |
|---|---|---|
diskpart |
Very high | list disk + list volume only |
format |
Very high | After confirming drive letter & backup |
clean |
Catastrophic | Only for full reinstall |
delete partition |
Catastrophic | Only for full repartitioning |
π Safe diskpart use
diskpart
list disk
list volume
exit
π¨ Never use
clean,format, ordelete partitionfor experimentation.
- Check disk number and size first
- Take a full backup
- Choosing the wrong disk may wipe entire system data
π Permission & Ownership Commands
Permission command table
| Command | Purpose | Example |
|---|---|---|
icacls |
View/modify permissions | icacls "C:\Reports" |
takeown |
Take ownership | takeown /f "C:\Old" /r /d y |
icacls "C:\Reports" :: View
icacls "C:\Reports" /save "C:\Temp\acl.txt" /t :: Save
icacls "C:\Reports" /restore "C:\Temp\acl.txt" :: Restore
takeown /f "C:\OldFolder" /r /d y :: Take ownership
β οΈ Warning: Do not randomly modify system folder permissions β may break Windows.
π― Quick CMD Commands by Problem
π If the internet is not working
ipconfig /all
ping 127.0.0.1
ping 192.168.1.1
ping 8.8.8.8
nslookup example.com
ipconfig /flushdns
ipconfig /release
ipconfig /renew
π‘ If the problem persists: Check the router, VPN, proxy, firewall, and network adapter driver.
π©Ί If Windows behaves abnormally
DISM /Online /Cleanup-Image /RestoreHealth
sfc /scannow
chkdsk C: /scan
β οΈ
chkdsk C: /fonly after saving your work and being ready to restart.
π If an app is frozen
tasklist | findstr /i "program.exe"
taskkill /im program.exe
π‘ Use
/fonly if the app is unresponsive.
π If the battery drains quickly
powercfg /batteryreport /output "%USERPROFILE%\Desktop\battery-report.html"
powercfg /energy /output "%USERPROFILE%\Desktop\energy-report.html" /duration 60
powercfg /requests
πΎ Back up a folder
robocopy "C:\Users\YourName\Documents" "D:\Backup\Documents" /E /Z /R:2 /W:5 /LOG:"D:\Backup\backup.log"
π« Commands You Should Never Run Casually
β Dangerous command list
| Command | Risk |
|---|---|
diskpart clean |
π Total data loss on the disk |
format |
π Wipe the entire volume |
rmdir /s |
β οΈ Delete a folder and all its contents |
del /s /q |
β οΈ Mass delete without confirmation |
shutdown /f |
β οΈ Force shutdown |
taskkill /f |
β οΈ Force-kill |
netsh winsock reset |
β οΈ Alters network stack |
netsh int ip reset |
β οΈ Alters TCP/IP settings |
icacls /reset |
β οΈ Loses custom permissions |
takeown /r |
β οΈ Changes ownership |
reg delete |
π Deletes Registry keys |
bcdedit |
π Can break boot |
π Note: These commands are not always forbidden, but they require:
- Clear context β
- A backup β
- A rollback plan β
βοΈ CMD vs. PowerShell: Which Should You Use?
Comparison table
| Task | CMD | PowerShell |
|---|---|---|
| Quick maintenance commands | β Suitable | β Also suitable |
| Managing Windows objects | β οΈ Limited | β Stronger |
| Structured object output | β οΈ Limited | β Excellent |
| Modern automation | β οΈ Less flexible | β Preferred |
| Running legacy Batch files | β Excellent | β Supported |
| Learning simple commands | β Easy start | β οΈ Needs extra concepts |
π‘ Info: Microsoft notes that PowerShell was designed to extend Command shell capabilities and recommends it for stronger, more modern automation. [1]
π How to Save a Command Set in a Batch File
Practical example: full system report
Create a .bat file with this content:
@echo off
set "REPORT=%USERPROFILE%\Desktop\windows-report"
mkdir "%REPORT%" 2>nul
systeminfo > "%REPORT%\systeminfo.txt"
ipconfig /all > "%REPORT%\network.txt"
tasklist > "%REPORT%\processes.txt"
echo Reports created at: "%REPORT%"
pause
π Explanation
| Command | Function |
|---|---|
@echo off |
Hide command echoing |
set |
Create a variable |
mkdir ... 2>nul |
Create folder (hide error) |
> |
Redirect output to a file |
pause |
Prevent immediate window close |
π¨ Security warning: Never run
.batfiles from unknown sources β they may contain destructive commands or privilege escalation.
β FAQ: Windows CMD Commands
π€ What is the most important command to diagnose and repair Windows?
Recommended order:
DISM /Online /Cleanup-Image /RestoreHealthsfc /scannow
π Note: This doesn’t mean both fix every issue β the problem may be in the disk, a driver, or third-party software.
π Do all CMD commands require Administrator rights?
| Type | Examples |
|---|---|
| β Usually work without admin | dir ping whoami ipconfig |
| β οΈ Require admin | sfc DISM chkdsk /f netsh powercfg |
π What is the difference between CMD and Command Prompt?
They refer to the same interface β cmd.exe β the shell built into Windows. PowerShell is a broader shell with different commands, data types, and scripting style.
π½ Does chkdsk /r improve disk speed?
No. Its purpose is to check file system errors and sectors and to recover readable information. It may take a long time and does not fix permanent hardware failure.
π§ Why is SFC not working?
| Possible cause | Solution |
|---|---|
| Window not elevated | Open CMD as Administrator |
| Windows image corrupted | Run DISM first |
| Disk issue | Check with chkdsk |
| System files locked | Try Safe Mode |
π How do I find my IP address in Windows?
ipconfig :: Basic
ipconfig /all :: Full details (DNS, DHCP, MAC)
π How do I kill a non-responsive program?
tasklist | findstr /i "program"
taskkill /im program.exe
π‘ Start with a normal termination, and only use
/fif the program does not respond.
πͺ Do CMD commands work on Windows 10 and 11?
Most basic commands work on both, but options and results may vary depending on:
- Windows version
- Privileges
- Installed components
Check /? and Microsoft documentation for the exact command before using an advanced option.
π οΈ Can CMD commands fully repair Windows?
No. They help diagnose:
- System files β
- Disk β
- Network β
- Processes β
But they cannot fix:
- Hardware problems β
- Viruses β
- Disk failure β
- Driver errors β
Sometimes you need Safe Mode, System Restore, Windows repair, or physical hardware inspection.
π― Conclusion
π Commands worth memorizing
systeminfo
ipconfig /all
ping 8.8.8.8
nslookup example.com
tasklist
DISM /Online /Cleanup-Image /RestoreHealth
sfc /scannow
chkdsk C: /scan
powercfg /batteryreport
robocopy "C:\Source" "D:\Backup" /E /Z
β Golden tips
| # | Tip |
|---|---|
| 1οΈβ£ | Choose the command based on the problem β don’t run commands randomly |
| 2οΈβ£ | Open CMD as Administrator only when needed |
| 3οΈβ£ | Back up your data before disk and repair commands |
| 4οΈβ£ | Stop at any unclear error message |
| 5οΈβ£ | Check the official documentation for exact options |
π‘ Remember: The official reference is always the best source for exact syntax and options supported in your Windows version.
π Related: