Command Prompt, usually called CMD or the CMD prompt, is the classic text-based shell in Windows. It is the program cmd.exe, it still ships with Windows 11, and it is still the quickest way to run things like ipconfig, ping or sfc /scannow.
To open it, press Win+R, type cmd and press Enter. To open it as administrator, press Ctrl+Shift+Enter instead of Enter.
What Command Prompt actually is
CMD is a command-line interpreter. It reads a line of text, runs the matching built-in command or program, and prints the result. Many of its commands date back to MS-DOS, but cmd.exe itself is a full 32-bit or 64-bit Windows application, not DOS.
You type a command
↓
cmd.exe parses it (built-in command, .exe, .bat or .cmd file)
↓
Windows runs it with your account's permissions
↓
Output appears as text in the window
The third step is why some commands only work in an elevated prompt: a command gets exactly the permissions of the window it was typed into.
How to open the CMD prompt in Windows 11
Method | Normal | As administrator |
|---|
Run dialog | Win+R, type cmd, Enter | Win+R, type cmd, Ctrl+Shift+Enter |
Start search | Press Win, type "cmd", Enter | Type "cmd", then click Run as administrator |
Quick Link menu | Win+X, Terminal, then open a Command Prompt tab | Win+X, Terminal (Admin), then a Command Prompt tab |
File Explorer | Type cmd in the address bar of any folder. It opens in that folder. | Not available |
Task Manager | File, Run new task, cmd | Same, and tick Create this task with administrative privileges |
Sudo (Windows 11 24H2+) | Not applicable | sudo <command> from a normal prompt, once enabled
|
An elevated window says Administrator: in its title bar. You need one for commands that change the system, such as sfc, DISM, chkdsk /f, netsh winsock reset and diskpart.
The File Explorer trick is the most underrated, because the prompt opens already sitting in the folder you were looking at. Sudo for Windows, available in 24H2 and later, is the newest option. Turn it on under Settings > System > Advanced, then run something like sudo netstat -ab. By default it shows a UAC prompt and opens the elevated command in a new window.
CMD, PowerShell and Windows Terminal
These get confused because they now open in the same window. Command Prompt and PowerShell are shells. Windows Terminal is the app that hosts them in tabs and panes, alongside WSL. On Windows 11 it is the default host, so typing cmd often opens Command Prompt inside a Terminal window. That is still the same cmd.exe, and everything here works in it.
The real difference between the two shells is what flows through the pipeline. CMD passes plain text and runs .bat and .cmd scripts. PowerShell passes .NET objects, runs .ps1 scripts and, as PowerShell 7, also runs on macOS and Linux. My rule is simple: CMD for quick commands, legacy scripts and repair tools, PowerShell for anything you would call automation, including Azure and Microsoft 365 administration.
Most CMD commands run unchanged in PowerShell because they are separate programs (ipconfig.exe, ping.exe). Built-ins such as dir and copy are the exception: in PowerShell they map to aliases with different options.
Getting help and working faster
help lists built-in commands. Add /? to any command for its options, for example robocopy /?.- Tab auto-completes file and folder names, and the Up arrow recalls previous commands.
command > out.txt saves output to a file, >> appends, and command | clip copies output to the clipboard.cmd1 && cmd2 runs the second command only if the first succeeds.- Ctrl+C stops a running command, such as a never-ending
ping -t. If a program ignores it, close the window or use taskkill from another prompt.
Microsoft's Windows commands reference documents every command and switch. If you are completely new to the prompt, Command Prompt basic commands is a gentler place to start.
Diagnosing a network problem
When "the internet is down", run these in order. Each step rules out one layer, so the first one that fails tells you where the break is.
:: 1. Do I have an IP address and a default gateway?
ipconfig
:: 2. Can I reach my router? (use your own gateway address)
ping 192.168.1.1
:: 3. Can I reach the internet by IP?
ping 8.8.8.8
:: 4. Does DNS work?
ping google.com
:: 5. Where along the path does it stop?
tracert google.com
If pinging an IP works but pinging a name fails, the problem is DNS. Try ipconfig /flushdns or a different DNS server. If you cannot even reach the gateway, the issue is between you and the router; our guide to 192.168.1.1 and router configuration picks up from there. ipconfig also answers the most common question people open CMD for: the IPv4 Address line under your active adapter is your private address. Your public address belongs to your router and shows up on any "what is my IP" website.
The other network problem developers hit constantly is an app that will not start because the address is already in use. netstat finds the process holding the port, and taskkill ends it:
netstat -ano | findstr :5000
TCP 127.0.0.1:5000 0.0.0.0:0 LISTENING 18244
tasklist /fi "pid eq 18244"
taskkill /pid 18244 /f
The rest of the network toolkit:
Command | What it does | Example |
|---|
ipconfig | Show IP address, subnet and default gateway | ipconfig /all
|
ipconfig /flushdns | Clear the DNS resolver cache | ipconfig /flushdns
|
ipconfig /release, /renew | Drop and request a new DHCP address | ipconfig /release && ipconfig /renew
|
ping | Test reachability and latency | ping -n 10 8.8.8.8
|
tracert | Show each router hop to a destination | tracert c-sharpcorner.com
|
pathping | Trace route plus packet loss per hop | pathping github.com
|
nslookup | Query DNS, optionally against a specific server | nslookup example.com 1.1.1.1
|
netstat | List connections and listening ports with process IDs | netstat -ano | findstr :5000
|
arp | Show IP-to-MAC mappings on the local network | arp -a
|
getmac | Show MAC addresses of adapters | getmac /v
|
route | Show or edit the routing table | route print
|
netsh wlan | Saved Wi-Fi profiles, including the stored key | netsh wlan show profile name="HomeWiFi" key=clear
|
curl | Make HTTP requests (built into Windows 10 and 11) | curl -I https://www.c-sharpcorner.com
|
Working with files and folders
Command | What it does | Example |
|---|
cd | Change directory. Add /d to switch drives too. | cd /d D:\Projects
|
dir | List files. /s recurses, /b gives bare names. | dir *.log /s /b
|
tree | Show folder structure | tree /f > structure.txt
|
mkdir (md) | Create a folder, including nested ones | mkdir src\api\Controllers
|
rmdir (rd) | Remove a folder. /s /q deletes its contents without asking. | rd /s /q bin
|
copy | Copy files | copy appsettings.json appsettings.bak
|
xcopy | Copy folders and subfolders | xcopy src D:\src /e /i
|
robocopy | Copy with retries, logging and mirroring | robocopy C:\Data D:\Backup /E /R:1 /W:1
|
move | Move or rename files and folders | move report.pdf D:\Archive\
|
ren | Rename. Wildcards work. | ren *.txt *.md
|
del | Delete files. /s recurses, /q skips prompts. | del /s *.tmp
|
type | Print a text file | type C:\Windows\System32\drivers\etc\hosts
|
attrib | View or change hidden, read-only and system attributes | attrib -h -s E:\* /s /d
|
where | Find which executable runs for a command | where dotnet
|
findstr | Search text in files or output | findstr /s /i "connectionstring" *.json
|
fc | Compare two files | fc old.config new.config
|
cls | Clear the screen | cls
|
where deserves more attention than it gets. When two versions of a tool are installed, it lists every match in PATH order, and the first one wins. It is also the first thing to run when CMD says a command "is not recognized as an internal or external command": either the name is misspelled or its executable is not in a folder on PATH. If you have just installed the tool, restart the terminal so it picks up the updated PATH.
System information and processes
Command | What it does | Example |
|---|
systeminfo | OS version, install date, uptime, RAM, hotfixes | systeminfo | findstr /b /c:"OS Name" /c:"OS Version"
|
ver | Show the Windows version number | ver
|
hostname | Show the computer name | hostname
|
whoami | Current user. /groups shows group membership. | whoami /groups
|
tasklist | List running processes | tasklist /fi "imagename eq dotnet.exe"
|
taskkill | End processes by name or PID | taskkill /im node.exe /f /t
|
shutdown | Shut down, restart, or schedule either | shutdown /r /t 0
|
set | Show or set environment variables for this session | set ASPNETCORE_ENVIRONMENT=Development
|
setx | Set a permanent user or system environment variable | setx DOTNET_CLI_TELEMETRY_OPTOUT 1
|
powercfg | Battery and power diagnostics | powercfg /batteryreport
|
driverquery | List installed drivers | driverquery /fo table
|
gpupdate | Re-apply Group Policy now | gpupdate /force
|
gpresult | Show which policies apply to you | gpresult /r
|
winget | Install, update and remove apps | winget upgrade --all
|
Environment variables trip people up in two ways. A variable set with set disappears when the window closes, while one set with setx only shows up in new windows. And never use setx to edit PATH: it truncates values longer than 1,024 characters. Edit PATH under Settings > System > About > Advanced system settings > Environment Variables instead.
For a closer look at processes, our Task Manager guide pairs each Task Manager page with its tasklist and taskkill equivalent.
You will still find wmic in old tutorials for hardware and process queries. Microsoft deprecated it years ago and has now removed it from all supported Windows 11 versions. Call PowerShell's CIM cmdlets from CMD instead:
powershell -c "Get-CimInstance Win32_BIOS | Select-Object SerialNumber"
powershell -c "Get-CimInstance Win32_Process | Select-Object Name, ProcessId"
Disks and drives
Command | What it does | Example |
|---|
chkdsk | Check and repair file system errors | chkdsk D: /f
|
chkdsk /scan | Online scan of an NTFS volume without taking it offline | chkdsk C: /scan
|
defrag | Optimize a drive (TRIM for SSDs, defragment for HDDs) | defrag C: /O
|
vol | Show volume label and serial number | vol C:
|
label | Change a drive's label | label E: BACKUP
|
diskpart | Partition and disk management (interactive) | diskpart, then list disk
|
format | Format a volume. Erases everything on it. | format E: /fs:ntfs /q
|
chkdsk's switches are worth getting right. With no switches, chkdsk C: only reports problems. /f fixes file system errors; on the system drive it cannot lock the volume, so it offers to run at the next restart, and you answer Y and reboot. /r also locates bad sectors and recovers readable data. It includes /f and can take hours on a large drive.
If chkdsk keeps finding new bad sectors, stop and back up the drive. Repeated sector errors usually mean the disk is failing.
Repairing Windows: DISM, then SFC
System File Checker verifies protected Windows files and replaces corrupted ones with good copies from the component store. DISM repairs that component store. If the store itself is damaged, SFC has nothing good to copy from, which is why Microsoft's System File Checker guidance says to run DISM first. Both need an elevated prompt.
:: Quick check, no repair
DISM /Online /Cleanup-Image /CheckHealth
:: Deeper scan, no repair
DISM /Online /Cleanup-Image /ScanHealth
:: Repair the component store (uses Windows Update as the source)
DISM /Online /Cleanup-Image /RestoreHealth
:: Then repair system files
sfc /scannow
RestoreHealth can sit at the same percentage for many minutes. That is normal; leave it running. SFC ends with one of three messages: it found no integrity violations, it found corrupt files and repaired them, or it found corrupt files but could not fix some of them. The details go to %windir%\Logs\CBS\CBS.log.
Other repair commands worth knowing:
Command | What it does | Example |
|---|
netsh winsock reset | Reset the network socket catalog (fixes some "connected, no internet" issues). Restart afterwards. | netsh winsock reset
|
netsh int ip reset | Reset TCP/IP settings to defaults | netsh int ip reset
|
shutdown /r /o | Restart into the Advanced startup options menu | shutdown /r /o /t 0
|
powercfg /energy | 60-second power efficiency report (HTML) | powercfg /energy
|
net user | List local accounts or show one account's details | net user %USERNAME%
|
reagentc | Check whether Windows Recovery Environment is enabled | reagentc /info
|
Batch file basics
A batch file is a text file with a .bat or .cmd extension that runs CMD commands in sequence. This one backs up your Documents folder and fails loudly if the copy fails:
@echo off
setlocal
:: Folders to copy (quotes handle spaces)
set "SRC=%USERPROFILE%\Documents"
set "DEST=D:\Backup\Documents"
if not exist "%DEST%" mkdir "%DEST%"
robocopy "%SRC%" "%DEST%" /E /R:1 /W:1 /NP /LOG+:"%DEST%\backup.log"
:: robocopy exit codes 8 and above mean failure
if %ERRORLEVEL% GEQ 8 (
echo Backup failed with code %ERRORLEVEL%
exit /b 1
)
echo Backup finished.
endlocal
Most of batch scripting is visible in that example. @echo off hides each command as it runs, and :: or rem starts a comment. set "NAME=value" defines a variable, %NAME% reads it, and setlocal stops variables leaking into the caller. if exist and if %ERRORLEVEL% GEQ n handle conditions, and exit /b 1 returns an error code.
A few pieces are not in the script. %1, %2 and so on are arguments, and %~dp0 is the folder the script lives in. for %%f in (*.log) do echo %%f loops over files; note the doubled %%f inside a script versus %f at the prompt. pause waits for a key press, which helps when someone double-clicks the script.
Schedule a script with Task Scheduler or call it from a CI pipeline. Once it grows past a page, rewrite it in PowerShell; it will be easier to read and to test.
Calling CMD from C#
Build tools and admin utilities often shell out to CMD. Run it with /c and capture the output:
using System.Diagnostics;
var psi = new ProcessStartInfo("cmd.exe", "/c ipconfig /all")
{
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
using var process = Process.Start(psi)!;
string output = await process.StandardOutput.ReadToEndAsync();
await process.WaitForExitAsync();
Console.WriteLine($"Exit code: {process.ExitCode}");
Console.WriteLine(output);
Never build that argument string from user input; it is a command injection hole. When input is involved, call the target executable directly and pass arguments through ArgumentList.
Habits that keep CMD safe
Command-line deletes skip the Recycle Bin, so the most important habit is checking where you are before del /s or rd /s /q. Run cd with no arguments, or just read the prompt. Quote any path with spaces, such as "C:\Program Files", because unquoted paths are a classic source of wrong-folder accidents.
Treat these commands with real caution:
format and diskpart, especially its clean command.rd /s /q and del /s /q.robocopy /MIR, which deletes destination files that are not in the source.bcdedit.
Elevate only when a command needs it, since a normal prompt cannot damage system files by accident. When testing a script, put echo in front of the destructive lines, check what it would have done, then remove the echo.
And never paste a command because a web page told you to. Fake "verify you are human" pages that ask you to press Win+R and paste something are a common way to install malware.
Is Command Prompt going away?
No. As of October 2026, cmd.exe still ships with Windows 11, and Windows Terminal includes a Command Prompt profile by default. Individual tools get retired, as WMIC was, but the shell itself remains. Learn the network and repair commands above and you will use them for years; when your scripts start needing real logic, that is the point to move them to PowerShell.
Join the conversation! Your thoughts help the community grow.