Skip to content
Advertisement

Useful CMD Commands for Windows 11 (2026 Reference)

SumitSumit···22 min read
Command Prompt window on a Windows desktop showing a list of commands

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.

CommandWhat it doesNeeds admin
cdChange folder, or show the current oneNo
dirList files and foldersNo
treeShow a folder structure as a treeNo
clsClear the screenNo
titleRename the current windowNo
colorChange text and background colourNo
echoPrint text or a variable, write to a fileNo
mkdir / mdCreate a folderNo
rmdir / rdDelete a folderNo
copyCopy filesNo
xcopyCopy files and foldersNo
robocopyFast, resumable copy and folder syncNo
moveMove filesNo
renRename a file or folderNo
delDelete filesNo
attribHide or unhide files and foldersNo
fcCompare two filesNo
assocShow which file type an extension maps toNo
systeminfoWindows version, install date, RAM, uptimeNo
hostname / verPC name / Windows build numberNo
driverqueryList installed driversNo
tasklistList running processesNo
taskkillEnd a processSometimes
ipconfigIP address, DNS cache, renew IPNo
pingTest if a host is reachableNo
tracertShow the route to a hostNo
nslookupLook up a domain's IP addressNo
netstatShow active connections and portsFor -b
netsh wlanWi-Fi profiles and saved passwordsSometimes
curlDownload a file or test a URLNo
sfc /scannowRepair protected system filesYes
DISMRepair the Windows imageYes
chkdskCheck a drive for errorsYes
diskpartManage disks and partitionsYes
shutdownShut down, restart, timer, advanced startupNo
powercfgBattery and sleep reportsSome reports
schtasksCreate and manage scheduled tasksSometimes
startOpen a new window, file, folder or URLNo
timeoutPause a script for a set timeNo
date / timeShow or set the date and timeTo set
whoamiShow the signed-in userNo
net userList or manage local accountsTo change
runasRun a program as another userNo
wingetInstall, update and remove appsSometimes

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 /registerdns

If 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.

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 folder

To 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\Photos

Folder 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.txt

The /a switch uses plain ASCII characters, which keeps the output readable when you paste it into an email or document.

cls, title and color

  • cls clears the screen.
  • title Backup running renames the window or tab. Useful when you have four CMD windows open and need to know which one is doing what.
  • color 0A changes background (first digit) and text (second digit). 0A is green on black. Type color /? for the full list, and color on 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.txt

The 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 /?.
  • help lists the built-in commands.
  • Press the Up arrow to recall previous commands, or F7 for a history list. doskey /history prints the history.
  • command | clip copies the output straight to the clipboard, for example ipconfig | 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 prompt

md 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:16 copies 16 files at a time, much faster for many small files.
  • /r:2 /w:5 retries a failed file twice, waiting 5 seconds, instead of the default one million retries.
  • /mir mirrors 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 *.log

del /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 below

This 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 compare

Handy for spotting what changed between two config files or two versions of a script.

assoc: check file associations

assoc .pdf
assoc .txt

assoc 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

  • hostname prints the PC name.
  • ver prints the Windows build number (for example 10.0.26100 for 24H2 and 10.0.26200 for 25H2). Type winver for the version window with the friendly name.

driverquery

driverquery
driverquery /v
driverquery /fo csv > drivers.csv

The 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 names

ipconfig /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.com

The 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=clear

The 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
  • /CheckHealth is a quick check for known corruption.
  • /ScanHealth is a deeper scan and takes several minutes.
  • /RestoreHealth finds 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: /r
  • chkdsk C: alone only reports, it does not fix.
  • /scan runs an online scan on NTFS drives while you keep working.
  • /f fixes errors. On the drive Windows runs from, it asks to schedule the check for the next restart.
  • /r also looks for bad sectors and recovers readable data. It implies /f and 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
exit

It 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 options

The 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
  • /batteryreport saves battery-report.html in the current folder. Compare Design capacity with Full charge capacity to see how worn your laptop battery is.
  • /energy runs a 60-second power efficiency check and needs admin.
  • /a lists the sleep states your PC supports.
  • /requests shows 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 cmd

start . 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 /nobreak

Pauses 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 /groups

whoami 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 administrators

These 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 /delete

These manage local accounts only. Accounts signed in with a Microsoft account are managed in Settings > Accounts.

runas

runas /user:Admin cmd

Runs 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 list
  • search finds the package ID. Use --id with -e (exact match) so winget does not pick a similarly named app.
  • upgrade lists apps with updates available; upgrade --all installs all of them in one go.
  • list shows 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.

SSumit

Sumit

Contributor

Hi, 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.

175 articles writtenView all posts by Sumit →

Related articles

See all