On this page
- Quick reference: CMD commands at a glance
- How to open Command Prompt on Windows 11
- Windows Terminal is now the default
- sudo for Windows
- Navigation and window basics
- cd: move between folders
- dir: list files and folders
- tree: see a folder structure
- cls, title and color
- echo: print text, variables, and write files
- Help and history
- Files and folders
- mkdir and rmdir: create and remove folders
- copy, xcopy and robocopy
- move, ren and del
- attrib: hide and unhide files
- fc: compare two files
- assoc: check file associations
- System information and processes
- systeminfo
- hostname and ver
- driverquery
- tasklist and taskkill
- WMIC is gone: what to use instead
- Network commands
- ipconfig
- ping
- tracert
- nslookup
- netstat
- netsh wlan: saved Wi-Fi networks and passwords
- curl
- Disk checks and Windows repair
- DISM, then sfc
- chkdsk
- diskpart
- Power and shutdown
- shutdown
- powercfg
- Scheduling and scripting
- schtasks
- start
- timeout
- date and time
- Users and accounts
- whoami
- net user and net localgroup
- runas
- Install and update apps with winget
- FAQs
- Is Command Prompt still available in Windows 11?
- What is the difference between CMD and PowerShell?
- Why does CMD say "'wmic' is not recognized"?
- How do I run Command Prompt as administrator?
- Are CMD commands case sensitive?
- Which commands fix most Windows problems?
Command Prompt (CMD) is still built into Windows 11, and it is still the fastest way to do a lot of small jobs: find your IP address, flush DNS, kill a frozen app, repair system files, or shut the PC down on a timer. You do not need to be a system admin to get value from it. A dozen commands cover most of what a normal user will ever need.
This guide is a reference for current Windows 11 builds (24H2, 25H2 and later). Every command below was checked against Microsoft's current command documentation, and the ones that changed recently are flagged: WMIC is gone, winget is built in, Windows Terminal is now the default window, and Windows 11 has its own sudo.
Quick reference: CMD commands at a glance
Search the table for a task or a command name. Each command has its own section further down with examples.
| Command | What it does | Needs admin |
|---|---|---|
cd | Change folder, or show the current one | No |
dir | List files and folders | No |
tree | Show a folder structure as a tree | No |
cls | Clear the screen | No |
title | Rename the current window | No |
color | Change text and background colour | No |
echo | Print text or a variable, write to a file | No |
mkdir / md | Create a folder | No |
rmdir / rd | Delete a folder | No |
copy | Copy files | No |
xcopy | Copy files and folders | No |
robocopy | Fast, resumable copy and folder sync | No |
move | Move files | No |
ren | Rename a file or folder | No |
del | Delete files | No |
attrib | Hide or unhide files and folders | No |
fc | Compare two files | No |
assoc | Show which file type an extension maps to | No |
systeminfo | Windows version, install date, RAM, uptime | No |
hostname / ver | PC name / Windows build number | No |
driverquery | List installed drivers | No |
tasklist | List running processes | No |
taskkill | End a process | Sometimes |
ipconfig | IP address, DNS cache, renew IP | No |
ping | Test if a host is reachable | No |
tracert | Show the route to a host | No |
nslookup | Look up a domain's IP address | No |
netstat | Show active connections and ports | For -b |
netsh wlan | Wi-Fi profiles and saved passwords | Sometimes |
curl | Download a file or test a URL | No |
sfc /scannow | Repair protected system files | Yes |
DISM | Repair the Windows image | Yes |
chkdsk | Check a drive for errors | Yes |
diskpart | Manage disks and partitions | Yes |
shutdown | Shut down, restart, timer, advanced startup | No |
powercfg | Battery and sleep reports | Some reports |
schtasks | Create and manage scheduled tasks | Sometimes |
start | Open a new window, file, folder or URL | No |
timeout | Pause a script for a set time | No |
date / time | Show or set the date and time | To set |
whoami | Show the signed-in user | No |
net user | List or manage local accounts | To change |
runas | Run a program as another user | No |
winget | Install, update and remove apps | Sometimes |
How to open Command Prompt on Windows 11
There are several ways in. Pick whichever is closest to your hands.
- Run box: press Windows + R, type
cmd, press Enter. Press Ctrl + Shift + Enter instead to open it as administrator. - Start search: press the Windows key, type
cmd, then pick Run as administrator on the right if you need admin rights. - Power user menu: press Windows + X (or right-click Start) and choose Terminal or Terminal (Admin). Terminal opens PowerShell by default; press Ctrl + Shift + 2 (Command Prompt is usually the second profile) or use the down arrow next to the tab to open a Command Prompt tab.
- File Explorer: click the address bar in any folder, type
cmd, press Enter. CMD opens already pointed at that folder.
Windows Terminal is now the default
Since Windows 11 version 22H2, CMD opens inside Windows Terminal instead of the old console window. You get tabs, split panes, better copy and paste, and settings for fonts and themes. The commands are the same. If you want Command Prompt to open by default in Terminal, open Terminal Settings > Startup > Default profile and choose Command Prompt.
Handy Terminal shortcuts:
- Ctrl + Shift + T: new tab
- Alt + Shift + D: split the pane
- Ctrl + Shift + scroll wheel: change window opacity, useful when you are copying commands from a web page behind it
- Ctrl + scroll wheel: change font size
sudo for Windows
Windows 11 version 24H2 and later include a sudo command, so you can run one command as administrator without opening a separate admin window. Turn it on in Settings > System > Advanced (on some builds it sits under System > For developers), switch on Enable sudo, and pick a mode. Inline behaves most like Linux: the command runs in the same window after you approve the UAC prompt.
sudo sfc /scannow
sudo ipconfig /registerdnsIf your PC is managed by work or school, the setting can be locked by policy. Without sudo, use one of the "Run as administrator" options above.
Navigation and window basics
cd: move between folders
cd (change directory) is the command you will type most.
cd Documents go into a folder
cd Documents\Projects go several levels at once
cd .. go up one level
cd \ jump to the root of the current drive
cd show the current folderTo switch drives, type the drive letter and a colon:
D:To switch drive and folder in one go, add /d. Without it, CMD changes the folder on the other drive but leaves you on the current one.
cd /d D:\Backups\PhotosFolder names with spaces need quotes: cd "Program Files". Press Tab to auto-complete file and folder names.
dir: list files and folders
dir lists what is in the current folder. Its switches are where it gets useful.
dir /a show everything, including hidden and system files
dir /a:h hidden files only
dir /a:d folders only
dir /o:s sort by size (smallest first), /o:-s for largest first
dir /o:d sort by date
dir /s *.pdf find every PDF in this folder and all subfolders
dir /b bare list, names only (good for piping to a file)Combine them: dir /s /b *.mp4 > videos.txt writes the full path of every MP4 under the current folder into a text file.
tree: see a folder structure
tree folders only
tree /f folders and files
tree /f /a > structure.txtThe /a switch uses plain ASCII characters, which keeps the output readable when you paste it into an email or document.
cls, title and color
clsclears the screen.title Backup runningrenames the window or tab. Useful when you have four CMD windows open and need to know which one is doing what.color 0Achanges background (first digit) and text (second digit).0Ais green on black. Typecolor /?for the full list, andcoloron its own to reset. The change lasts only for that window; for permanent colours, change the profile's colour scheme in Windows Terminal settings.
echo: print text, variables, and write files
echo %USERNAME%
echo %COMPUTERNAME%
echo %PATH%
echo %TEMP%
echo %DATE% %TIME%Redirect output to a file with > (overwrite) or >> (append):
echo First line > notes.txt
echo Second line >> notes.txtThe same redirection works with any command: ipconfig /all > network.txt saves your network details for later.
Help and history
- Add
/?to any command to see its options:robocopy /?. helplists the built-in commands.- Press the Up arrow to recall previous commands, or F7 for a history list.
doskey /historyprints the history. command | clipcopies the output straight to the clipboard, for exampleipconfig | clip.
Files and folders
mkdir and rmdir: create and remove folders
mkdir Reports
mkdir Reports\2026\October creates every missing level at once
rmdir Reports\Old removes an empty folder
rmdir /s /q Reports\Old removes the folder and everything inside it, no promptmd and rd are short forms of the same commands. Be careful with /s /q: deleted files do not go to the Recycle Bin.
copy, xcopy and robocopy
copy handles single files or simple wildcards:
copy report.docx D:\Backup\
copy *.jpg D:\Photos\xcopy copies folders and subfolders:
xcopy C:\Projects D:\Projects /e /i /h/e includes empty subfolders, /i assumes the destination is a folder, /h includes hidden files.
robocopy (Robust File Copy) is the one to learn. It resumes after interruptions, retries failed files, copies with multiple threads, and only copies files that changed.
robocopy C:\Projects D:\Projects /e
robocopy C:\Projects D:\Projects /e /mt:16 /r:2 /w:5
robocopy C:\Projects D:\Projects /mir/mt:16copies 16 files at a time, much faster for many small files./r:2 /w:5retries a failed file twice, waiting 5 seconds, instead of the default one million retries./mirmirrors the source. It also deletes files from the destination that no longer exist in the source, so double-check the paths before you run it.
For keeping two folders in sync on a schedule, combine robocopy with schtasks (below), or see our guide on how to sync multiple folders in Windows.
move, ren and del
move report.docx D:\Archive\
ren draft.txt final.txt
ren *.jpeg *.jpg
del old-log.txt
del /s /q *.tmp
del /p *.logdel /p asks before each file, a safe habit with wildcards. Like rmdir, del skips the Recycle Bin.
attrib: hide and unhide files
attrib changes file attributes. +h is hidden, +s is system. Files marked hidden and system stay invisible in File Explorer even when "Show hidden files" is on.
attrib +h +s secret.txt hide a file
attrib -h -s secret.txt unhide it
attrib +h +s *.mp4 hide every MP4 in this folder
attrib +h +s "New Folder" /d hide a folder
attrib -h -s /s /d * unhide everything in this folder and belowThis hides files from casual browsing; it is not encryption. Our guide on how to hide a folder in Windows covers the File Explorer method and stronger options.
fc: compare two files
fc old.txt new.txt
fc /n old.txt new.txt show line numbers
fc /b image1.png image2.png binary compareHandy for spotting what changed between two config files or two versions of a script.
assoc: check file associations
assoc .pdf
assoc .txtassoc shows the file type an extension is linked to. To change which app opens a file type, use Settings > Apps > Default apps; changing associations from CMD is unreliable on Windows 11.
System information and processes
systeminfo
systeminfo prints the Windows edition and build, install date, last boot time, BIOS version, RAM and installed updates.
systeminfo
systeminfo | findstr /b /c:"OS Name" /c:"OS Version" /c:"System Boot Time"The second line filters the output down to the fields you care about. findstr is CMD's text filter and works with the output of any command.
hostname and ver
hostnameprints the PC name.verprints the Windows build number (for example 10.0.26100 for 24H2 and 10.0.26200 for 25H2). Typewinverfor the version window with the friendly name.
driverquery
driverquery
driverquery /v
driverquery /fo csv > drivers.csvThe CSV version opens in Excel, which makes it easy to sort by date and spot old drivers. To actually update them, follow our guide on how to update drivers on Windows 11.
tasklist and taskkill
tasklist lists every running process with its PID (process ID) and memory use.
tasklist
tasklist /fi "imagename eq chrome.exe"
tasklist /fi "memusage gt 500000"The last line shows processes using more than about 500 MB.
taskkill ends a process by name or PID:
taskkill /im notepad.exe
taskkill /im chrome.exe /f
taskkill /pid 4120 /f
taskkill /im chrome.exe /f /t/f forces it to close, /t also kills its child processes. Ending system processes needs an admin window, and ending the wrong one can crash Windows, so check the name first.
WMIC is gone: what to use instead
Older guides, including the previous version of this one, used wmic for things like reading the BIOS serial number. Microsoft has now removed WMIC from supported versions of Windows 11. It was disabled by default in 23H2 and 24H2, removed on upgrade to 25H2, and dropped entirely with the August 2026 preview update for 24H2 and 25H2. It is no longer available as an optional feature either.
WMI itself still works. Call it through PowerShell, which you can do from CMD:
powershell -c "(Get-CimInstance Win32_BIOS).SerialNumber"
powershell -c "Get-CimInstance Win32_ComputerSystem | Select-Object Manufacturer, Model"
powershell -c "Get-CimInstance Win32_DiskDrive | Select-Object Model, Size"
powershell -c "Get-CimInstance Win32_Process | Select-Object Name, ProcessId"Network commands
ipconfig
ipconfig shows your local IP address, subnet mask and default gateway (usually your router).
ipconfig
ipconfig /all adds MAC address, DNS servers, DHCP lease times
ipconfig /flushdns clears the DNS cache
ipconfig /displaydns shows what is in the DNS cache
ipconfig /release drops the current IP address
ipconfig /renew asks the router for a new one
ipconfig /registerdns refreshes DHCP leases and re-registers DNS namesipconfig /flushdns is the fix when a site moved to a new server and your PC keeps loading the old one, or when a page will not load on one PC but works on others. /release followed by /renew often fixes "connected, no internet" problems.
ping
ping checks whether a host responds and how long it takes.
ping google.com
ping -n 10 192.168.1.1
ping -t 8.8.8.8
ping -4 google.com-n sets the number of tries, -t keeps going until you press Ctrl + C, -4 forces IPv4. Pinging your router first, then a public address, tells you quickly whether a problem is your Wi-Fi or your internet line. Some servers block ping, so a timeout does not always mean the site is down.
tracert
tracert lists every hop between your PC and a destination, with the delay at each one.
tracert google.com
tracert -d google.com-d skips name lookups and runs much faster. If delays jump at the second or third hop, the slowdown is usually at your internet provider, not your PC.
nslookup
nslookup asks DNS for a domain's IP address, the quick way to find the IP of a website.
nslookup thetechbasket.com
nslookup thetechbasket.com 1.1.1.1
nslookup -type=mx gmail.comThe second line asks a specific DNS server (here Cloudflare's), which helps when you suspect your provider's DNS is giving stale answers. -type=mx shows a domain's mail servers.
netstat
netstat shows active network connections and listening ports.
netstat -ano
netstat -ano | findstr :443
netstat -b-a shows all connections and listening ports, -n shows numbers instead of names (faster), -o adds the PID so you can match a connection to a process in tasklist. -b shows the program name directly but needs an admin window.
netsh wlan: saved Wi-Fi networks and passwords
netsh wlan show profiles
netsh wlan show profile name="Home WiFi" key=clearThe second command shows the saved password for that network under Key Content. Run it from an admin window if the key does not appear. netsh wlan show interfaces shows your current signal strength and connection speed.
curl
curl has shipped with Windows since 2018, so you can download a file or test a web address without a browser:
curl -I https://www.thetechbasket.com
curl -L -o setup.exe https://example.com/setup.exe-I fetches only the headers (status code, server, cache), -L follows redirects, -o saves to a file.
Disk checks and Windows repair
These three are the first thing to try when Windows is crashing, apps fail to open, or updates keep failing. All of them need an admin window (or sudo).
DISM, then sfc
Microsoft's recommended order is DISM first, then SFC. DISM repairs the Windows component store that SFC copies good files from; if that store is damaged, SFC cannot fix anything.
DISM /Online /Cleanup-Image /CheckHealth
DISM /Online /Cleanup-Image /ScanHealth
DISM /Online /Cleanup-Image /RestoreHealth
sfc /scannow/CheckHealthis a quick check for known corruption./ScanHealthis a deeper scan and takes several minutes./RestoreHealthfinds and repairs damage, downloading clean files from Windows Update. It can sit on one percentage for several minutes; leave it running.sfc /scannow(System File Checker) then scans protected system files and replaces damaged ones.
Restart after both finish. If they report errors they could not fix, the next step is a repair install or reset; our guide on how to factory reset a Windows laptop covers the keep-my-files option.
chkdsk
chkdsk checks a drive's file system for errors.
chkdsk C:
chkdsk C: /scan
chkdsk D: /f
chkdsk D: /rchkdsk C:alone only reports, it does not fix./scanruns an online scan on NTFS drives while you keep working./ffixes errors. On the drive Windows runs from, it asks to schedule the check for the next restart./ralso looks for bad sectors and recovers readable data. It implies/fand can take hours on a large hard drive.
On SSDs, chkdsk /r is rarely needed; /scan and /f cover file system problems.
diskpart
diskpart opens its own prompt for managing disks, partitions and volumes.
diskpart
list disk
select disk 1
list partition
list volume
exitIt can also clean a disk, create partition primary, format fs=ntfs quick and assign letter=E, which is how you rescue a USB drive that File Explorer refuses to format. Those commands erase data with no undo, so run list disk and confirm the disk number by its size before you select anything. For everyday partition changes, Disk Management (right-click Start) is safer.
Power and shutdown
shutdown
shutdown /s /t 0 shut down now
shutdown /r /t 0 restart now
shutdown /s /t 3600 shut down in one hour
shutdown /a cancel a pending shutdown
shutdown /h hibernate
shutdown /l sign out
shutdown /r /o /t 0 restart into Advanced startup optionsThe timer is in seconds, so /t 3600 is a sleep timer for a long download or a film. /r /o takes you straight to the blue recovery menu (Safe Mode, Startup Repair, UEFI settings) without holding Shift while clicking Restart. Add /f to force apps to close without waiting.
powercfg
powercfg /batteryreport
powercfg /energy
powercfg /a
powercfg /requests/batteryreportsavesbattery-report.htmlin the current folder. Compare Design capacity with Full charge capacity to see how worn your laptop battery is./energyruns a 60-second power efficiency check and needs admin./alists the sleep states your PC supports./requestsshows what is preventing sleep, for example a browser playing audio. Needs admin.
Scheduling and scripting
schtasks
schtasks is the command-line side of Task Scheduler.
schtasks /create /sc daily /st 09:00 /tn "Morning Backup" /tr "C:\Scripts\backup.bat"
schtasks /query /tn "Morning Backup"
schtasks /run /tn "Morning Backup"
schtasks /delete /tn "Morning Backup" /f/sc sets the schedule (daily, weekly, onlogon, onstart), /tn the task name, /tr the program or script to run. onlogon and onstart tasks need an admin window. A batch file that opens your usual apps, run at logon, is a neat alternative to a crowded startup list; our guide on how to disable startup programs in Windows includes a ready-made batch file for that.
start
start notepad
start .
start https://www.thetechbasket.com
start "" "C:\Program Files\App\app.exe"
start cmdstart . opens the current folder in File Explorer. When the path has quotes, put an empty "" first, because start treats the first quoted text as the window title.
timeout
timeout /t 10
timeout /t 30 /nobreakPauses for the given number of seconds. In batch files it spaces out steps, for example waiting for a network drive before copying to it. /nobreak ignores key presses.
date and time
date /t
time /t/t shows the value without asking for a new one. To set the date or time, type date or time in an admin window and enter the new value in the format shown, which follows your region settings. If Set time automatically is on in Settings > Time & language > Date & time, Windows overwrites your change on the next sync.
Users and accounts
whoami
whoami
whoami /groupswhoami shows the signed-in user as PCNAME\username. /groups lists the groups the account is in, a quick way to confirm whether you are an administrator.
net user and net localgroup
net user
net user sumit
net localgroup administratorsThese list local accounts, show details for one account (last logon, password expiry), and list everyone with admin rights. From an admin window you can also make changes:
net user guestuser * /add
net localgroup administrators guestuser /add
net user guestuser /active:no
net user guestuser /deleteThese manage local accounts only. Accounts signed in with a Microsoft account are managed in Settings > Accounts.
runas
runas /user:Admin cmdRuns a program as another account after asking for that account's password. On a single-user PC, sudo or Run as administrator is simpler. When a folder refuses access even as admin, see how to take ownership of folders and files.
Install and update apps with winget
winget (Windows Package Manager) comes with Windows 11 through the App Installer package, so it works in CMD out of the box.
winget search firefox
winget install --id Mozilla.Firefox -e
winget upgrade
winget upgrade --all
winget uninstall --id Mozilla.Firefox -e
winget listsearchfinds the package ID. Use--idwith-e(exact match) so winget does not pick a similarly named app.upgradelists apps with updates available;upgrade --allinstalls all of them in one go.listshows installed apps, including ones not installed through winget.
Some installs trigger a UAC prompt. winget upgrade --all is the single most useful command for keeping a fresh PC up to date, and pairs well with the tools in our list of best Windows utilities.
FAQs
Is Command Prompt still available in Windows 11?
Yes. CMD is still part of Windows 11 and is not being removed. It now opens inside Windows Terminal by default, alongside PowerShell, but every command in this guide works the same way.
What is the difference between CMD and PowerShell?
CMD runs classic commands and batch files and is simple to learn. PowerShell is a full scripting language that works with objects, can manage almost every part of Windows, and replaces tools like WMIC. For quick jobs, CMD is fine. For automation, learn PowerShell. Most CMD commands, including ipconfig, ping and sfc, also work in PowerShell.
Why does CMD say "'wmic' is not recognized"?
Microsoft removed WMIC from supported Windows 11 versions in 2026. Use powershell -c "Get-CimInstance <class>" instead, for example powershell -c "(Get-CimInstance Win32_BIOS).SerialNumber" for the serial number.
How do I run Command Prompt as administrator?
Press Windows + R, type cmd, and press Ctrl + Shift + Enter. Or press Windows + X and choose Terminal (Admin). On Windows 11 24H2 and later you can also enable sudo and type sudo before a single command.
Are CMD commands case sensitive?
No. IPCONFIG, ipconfig and IpConfig all work. File and folder names are not case sensitive on Windows either. Some third-party tools you run from CMD may treat their own options as case sensitive.
Which commands fix most Windows problems?
Run DISM /Online /Cleanup-Image /RestoreHealth, then sfc /scannow, then chkdsk C: /f (which runs at the next restart), all from an admin window. For network problems, try ipconfig /flushdns, then ipconfig /release and ipconfig /renew.

Sumit
ContributorHi, I'm Sumit, Being an introvert I have always been obsessed with technology-computers and reading dozens of posts to learn, find answers out of my curiosity. I love to write as I explore more.






