Mastering the Windows 11 Command Prompt (CMD) lets you bypass cluttered graphical settings menus and troubleshoot system issues in seconds. While Microsoft has pushed PowerShell as the default administrative shell, CMD remains a lightweight, reliable environment for everyday system maintenance, network diagnostics, and quick file management. Whether you're running scripts or fixing a broken boot sector, knowing the right commands saves valuable time.
This guide breaks down practical CMD workflows, essential system utilities, and advanced command-line techniques for Windows 11. You'll learn how to clean up disk space, repair corrupted system files, troubleshoot network dropouts, and automate routine tasks without installing third-party software.
Accessing Command Prompt with Administrator Rights
Many powerful commands require elevated privileges to modify system files, change network configurations, or access protected directories. Opening standard CMD limits what you can execute.
Methods to Launch Elevated CMD
- Start Menu Search: Press the Windows key, type
cmd, right-click Command Prompt in the results, and select Run as administrator. - Power User Menu: Press
Windows Key + Xon your keyboard, then select Terminal (Admin) or Command Prompt (Admin) from the pop-up list. - Task Manager Shortcut: Press
Ctrl + Shift + Escto open Task Manager, click Run new task, typecmd, check the box for Create this task with administrative privileges, and hit Enter.
Once open, verify the title bar reads Administrator: Command Prompt to ensure you have the necessary permissions for system-level operations.
Essential System Diagnostics and Repair
When Windows 11 behaves sluggishly or throws mysterious error codes, built-in command-line tools can diagnose and repair the underlying operating system corruption.
Checking File Integrity with SFC
The System File Checker (SFC) scans all protected system files and replaces corrupted, modified, or missing versions with cached copies located in a compressed folder at %WinDir%\System32\dllcache.
Run this command to initiate a scan:
sfc /scannow
The scan takes between five and fifteen minutes depending on your storage drive speed. If SFC finds integrity violations, it attempts automatic repairs. Restart your computer immediately if prompted.
Repairing the Windows Image with DISM
If SFC fails to repair damaged system files because the local cache is corrupted, you need to use the Deployment Image Servicing and Management (DISM) tool. DISM connects to Windows Update to download fresh, uncorrupted system files.
Execute the restoration command:
DISM /Online /Cleanup-Image /RestoreHealth
This process requires an active internet connection. For deeper diagnostics without making changes, you can run /CheckHealth or /ScanHealth first. Combining DISM and SFC—running DISM first, followed by SFC—is the standard recovery sequence for unstable Windows installations.
Disk Management and Storage Cleanup
Managing storage efficiently prevents performance degradation. Instead of navigating through multiple settings panes, use built-in disk utilities to analyze partitions and reclaim gigabytes of wasted space.
Diskpart Operations
Diskpart is a powerful partitioning utility. Improper use can lead to permanent data loss, so proceed with caution. To view connected drives, open diskpart and list the volumes:
diskpart
list volume
exit
For checking file system integrity on a specific drive partition without entering the interactive diskpart environment, use the Check Disk utility:
chkdsk C: /f /r
The /f parameter fixes errors on the disk, while /r locates bad sectors and recovers readable information. Running this on your primary drive (C:) usually requires scheduling the scan for the next system restart.
Purging Temporary Files
Windows accumulates gigabytes of temporary data over time. You can clear out user temp files directly from the command line without opening third-party cleaners:
del /q /f /s "%TEMP%\*"
This command deletes files inside the current user's temporary folder quietly (/q), forces the deletion of read-only files (/f), and includes files in subdirectories (/s). Files currently locked by active applications will throw harmless skip warnings.
Network Troubleshooting Utilities
When your internet drops or websites fail to load, network command-line tools pinpoint whether the issue stems from your local adapter, your router, or your Internet Service Provider (ISP).
Diagnosing IP Configurations
To check your computer's current IP address, subnet mask, and default gateway, run:
ipconfig /all
If your network adapter is failing to pull a valid IP address from your router, release the current lease and request a new one using these commands:
ipconfig /release
ipconfig /renew
Flushing the DNS Cache
Corrupted Domain Name System (DNS) cache entries cause connection errors where known websites fail to load. Clear out outdated cached domain resolutions by running:
ipconfig /flushdns
Tracing Network Paths and Latency
To test latency and packet loss between your computer and a specific server or website, use the ping utility:
ping 8.8.8.8 -t
The -t flag pings the destination continuously until you press Ctrl + C to stop it. If you want to see every router hop your data takes across the internet to reach a destination, use tracert:
tracert microsoft.com
For more detailed technical documentation on networking commands, consult the Microsoft Learn Networking Documentation.
Managing Windows Services and Processes
Automating or troubleshooting background software requires interacting with running processes and Windows services directly from the command line.
Viewing Active Tasks
To generate a complete list of currently running processes along with their Process IDs (PIDs) and memory consumption, execute:
tasklist
If a misbehaving application freezes and refuses to close through the graphical interface, kill it instantly by targeting its PID or image name:
taskkill /im notepad.exe /f
The /f parameter forces termination, preventing the application from hanging indefinitely.
Controlling System Services
Services run in the background to handle features like audio, print spooling, and Windows Update. To query the status of a specific service, such as the Windows Update service (wuauserv), run:
sc query wuauserv
You can also start or stop services directly when troubleshooting software conflicts:
sc stop wuauserv
sc start wuauserv
Automating Workflows with Batch Scripts
Typing repetitive commands becomes tedious. You can combine multiple commands into a batch script (.bat) to automate system maintenance tasks.
Create a new text file using Notepad, paste your preferred maintenance commands, and save the file with a .bat extension (for example, maintenance.bat). A basic maintenance script looks like this:
@echo off
echo Starting system maintenance...
DISM /Online /Cleanup-Image /RestoreHealth
sfc /scannow
ipconfig /flushdns
echo Maintenance complete.
pause
Right-click your saved batch file and select Run as administrator to execute the entire sequence sequentially. For deeper insights into scripting logic and environment variables, review the Microsoft Scripting Reference.
Frequently Asked Questions
Is Command Prompt being replaced by PowerShell?
Microsoft encourages users to adopt PowerShell or the modern Windows Terminal for advanced administrative workflows because they offer richer object-based scripting capabilities. However, Command Prompt remains fully supported in Windows 11 for legacy batch scripts and quick troubleshooting tasks.
Do I always need administrator privileges to run these commands?
No. Commands that only query information or affect the current user profile—such as ipconfig, ping, tasklist, and user temp file cleanup—work fine in a standard command prompt. Commands that modify system files, repair disk partitions, or alter network adapters require administrative rights.
What happens if sfc /scannow finds unrepairable files?
If SFC cannot fix corrupted system files, it typically points you toward running the DISM repair command first (DISM /Online /Cleanup-Image /RestoreHealth). Once DISM repairs the underlying Windows component store image, running SFC a second time usually resolves remaining file corruptions successfully.
Can I run Linux commands inside Windows 11 Command Prompt?
Standard CMD only runs native Windows commands. If you need native Linux utilities like grep, awk, or ssh directly inside your command-line environment, install the Windows Subsystem for Linux (WSL) via PowerShell by running wsl --install.