Windows Command Prompt is a powerful tool for automating tasks, managing files, and troubleshooting system issues—all without opening a browser or graphical app. The right commands can save hours of manual work, and mastering even a few key ones makes your PC feel more efficient than ever. Unlike GUI menus, which can be slow for repetitive actions, the command line gives you direct, precise control over every aspect of your system.
What You'll Need
- A Windows PC (Windows 10 or 11), with administrative privileges for some commands (e.g., system changes, network admin tasks).
- An active internet connection for commands that require downloading files (like PowerShell scripts or updates).
- Basic familiarity with file structures (e.g., knowing where your Documents folder is) to navigate directories efficiently.
- A keyboard—because typing commands is faster than clicking menus.
Step-by-Step: Essential Windows Command Prompt Commands
- Open Command Prompt:
- Press Win + R, type cmd, and hit Enter. Alternatively, search for "Command Prompt" in the Start menu.
- For elevated (admin) access, right-click "Command Prompt" > Run as administrator in the context menu.
- If you’re using Windows 10/11’s built-in PowerShell by default, you can switch back to CMD by selecting "Command Prompt" from the Start menu search.
- Basic Navigation:
cd(Change Directory) – Move between folders.cd \– Go to the root (C:) drive.cd Documents– Navigate into your Documents folder.cd ..– Move up one folder level.
dir– List files and folders in the current directory.dir /p– Pause after each screenful of results.dir /w– Wide format (shows filenames in 20-character widths).
cls– Clear the command prompt screen.
- File Operations:
copy– Copy files/folders.copy file.txt C:\Backup\– Save a file to a backup folder.copy *.txt C:\TextFiles\– Copy all .txt files recursively.
move– Rename or relocate files.move oldfile.txt newfolder\– Move a file into a folder.- For renaming:
move file.txt renamedfile.txt.
delete– Remove files (be careful with wildcards!).rd(Remove Directory) – Delete empty folders.rd folder1 /s /q– Force-delete all subfolders and suppress prompts.
- Disk Management:
diskpart– Open the disk partitioning tool.- Type
list diskto see available drives. - Select a drive with
select disk X(replace X with your drive number). - List partitions with
list partition. - Create a new partition:
create partition primary. - Exit with
exit.
- Type
format– Reformat a drive (use with caution!).format C: /fs:NTFS /q– Quick-format drive C: with NTFS (admins only).
- System Information:
systeminfo– Display full system details (CPU, RAM, OS version, etc.).wmic cpu get name, loadpercentage– Check CPU usage by name and load.tasklist– List running processes (useful for killing stuck apps).ipconfig– Show network details (IP, DNS, adapter info).netstat -ano– List active network connections and their PID.
- Networking:
ping– Test connectivity to a host.ping google.com– Check if the internet works.ping -t google.com– Ping continuously until stopped.
net use– Map network drives.net use Z: \\server\share /user:domain\username– Connect to a shared folder.- To disconnect:
net use Z: /delete.
arp -a– View ARP cache (shows IP-to-MAC mappings).
- Automation & Scripting:
for /f– Loop over files or text (beginner-friendly).for /f "tokens=*" %i in ('dir *.txt') do echo %i– List all .txt files in the current directory.
if exist– Conditional checks.if exist file.txt echo Found!– Check if a file exists.
start– Run an app or script in a new window.start notepad.exe– Open Notepad in a new window.start "" "C:\script.bat"– Run a batch file silently.
type– View file contents.type C:\notes.txt– Display file text.
- Advanced: PowerShell Integration:
- Run PowerShell as Admin:
powershell -Command "Start-Transcript -Path C:\log.txt"– Start logging all PowerShell output. - Execute PowerShell scripts from CMD:
powershell -ExecutionPolicy Bypass -File script.ps1– Run a script even if restricted.
- Run PowerShell as Admin:
- Backup & Recovery:
robocopy– Advanced file copying (robust for backups).robocopy C:\source D:\backup /E /ZB– Copy all folders (including subdirectories) with error handling.- /mir – Mirror directory tree (copy only new/changed files).
chkdsk– Check and repair disk errors.chkdsk C: /f /r– Fix errors on drive C: (run as admin).
Common Mistakes
- Forgetting admin rights: Many commands (e.g., `delete`, `format`, `diskpart`) require admin privileges. Always run as admin unless you’re only reading files.
- Wildcards without care: Commands like `delete *.tmp` will delete everything with those extensions—double-check before running.
- Overwriting files: Use `move` instead of `copy` to avoid accidental renames. For example, `move file.txt newfile.txt` adds a `.txt` extension.
- Ignoring drive letters: Typing `format C:` without `/q` will prompt for confirmation—always include `/q` for silent formatting.
- Mixing CMD and PowerShell: Avoid mixing the two unless you know how (e.g., `powershell -Command "cmd /c echo Test"`). Stick to one for consistency.
Tips
- Use shortcuts: Press Ctrl + Shift + N to create a new folder in CMD (faster than typing `mkdir`).
- Learn keyboard shortcuts:
Tabauto-completes commands and filenames (e.g., `cd D:\Users\A` + Tab auto-fills). - Save frequent commands: Create a batch file (`.bat`) with your most-used commands for quick access.
- Check for updates: Run
wmic qfe listto see installed updates, or usepowershell -Command "Get-HotFix"for deeper checks. - Use `where` for apps:
where notepad.exefinds the installation path of an app.
Troubleshooting
- Command not found:
- Ensure the command exists (e.g., `dir` is built-in; `robocopy` is in Windows 10/11).
- Try typing it fully (e.g.,
copyfile.txt C:\backup\>copy file.txt C:\backup\). - If missing, you may need to enable "Command Prompt" in Windows Features:
- Open "Turn Windows features on or off" via Win + R, type optionalfeatures, and check "Windows PowerShell" (for `robocopy`).
- Permission denied:
- Run CMD as admin (right-click > "Run as administrator").
- For system commands (e.g., `diskpart`), ensure you’re not in a non-admin session.
- Network issues:
- Restart your router/modem.
- Run
ipconfig /flushdnsto clear DNS cache. - Check for VPN/proxy interference (disable if needed).
- Stuck on a command:
- Press Ctrl + C to interrupt a command.
- Use
exitin PowerShell orexit>to leave CMD.
- No internet access:
- Verify your connection with
pinggoogle.com. - If offline, commands like `update`, `download`, or `robocopy` will fail.
- Verify your connection with
Frequently Asked Questions
How do I open Command Prompt with admin rights?
Open it normally, right-click the Command Prompt icon > "Run as administrator" in the context menu.Can I use CMD commands on Windows 11 to format a new SSD?
Yes, but only as admin. Use:diskpart > create partition primary > format fs=ntfs quick > assign (then exit diskpart).
What’s the difference between `cd` and `md`?
cd changes your current directory, while md (make directory) creates a new folder. Example:
md NewFolder creates a folder; cd NewFolder navigates into it.
How do I backup my entire user profile using CMD?
Use Robocopy:robocopy C:\Users\YourName D:\Backup\UserFolder /E /ZB /R:1 /W:5
(E = includes subfolders, /ZB = restart on errors, /R:1 = retry once, /W:5 = wait 5 sec between retries).
Can I list all installed programs from CMD?
Yes, but you’ll need PowerShell:powershell -Command "(Get-WmiObject -Class Win32_Product).Name" | sort
For CMD-only: Install "where" via Windows Features (see troubleshooting).
Why does `format C:` prompt me for a drive letter?
Windows 10/11 skips the drive letter prompt for local drives by default. Force it with:format C: /f:1024 /q (where /f:1024 = sector size in KB, /q = quiet mode).