All CMD Commands for Windows
Basics 23
Type in Command PromptWhat it does
Get started
helpLists the built-in commands.
ipconfig /?Shows any command's options.
clsClears the screen.
exitCloses Command Prompt.
verShows your Windows version.
Move around
cdShows the folder you are in.
cd DocumentsOpens a folder.
cd ..Goes up one folder.
cd \Goes to the top of the drive.
d:Switches to drive D.
cd /d D:\ProjectsSwitches drive and folder at once.
pushd D:\ProjectsSaves this folder and opens another.
popdGoes back to the saved folder.
Handy tricks
start .Opens this folder in File Explorer.
start notepadOpens an app.
where notepadShows where a program is.
doskey /historyLists the commands you typed.
ipconfig | clipCopies a command's output.
ipconfig > info.txtSaves the output to a file.
ipconfig >> info.txtAdds the output to a file.
title BackupRenames the window.
color 0aGreen text on black.
colorPuts the colors back.
Files and folders 43
Type in Command PromptWhat it does
See files
dirLists files and folders.
dir /aIncludes hidden files.
dir /s /b *.pdfFinds every PDF in all subfolders.
dir /o:-sBiggest files first.
dir /o:-dNewest files first.
tree /fShows folders and files as a tree.
type notes.txtShows a text file.
more log.txtShows a long file one page at a time.
Create and delete
md ProjectsCreates a folder.
md Projects\2026\PhotosCreates folders inside folders.
ren notes.txt todo.txtRenames a file.
ren *.txt *.mdChanges the extension of many files.
move notes.txt D:\BackupMoves a file.
del notes.txtDeletes a file, skipping the Recycle Bin.
del /s /q *.tmpDeletes every .tmp file in subfolders.
rd ProjectsRemoves an empty folder.
rd /s /q ProjectsRemoves a folder and everything in it.
Copy and back up
copy notes.txt D:\BackupCopies a file.
copy *.jpg D:\PhotosCopies every JPG.
copy a.txt+b.txt all.txtJoins two files into one.
xcopy D:\Photos E:\Photos /e /h /iCopies a folder with hidden files.
robocopy D:\Photos E:\Photos /eCopies a folder and all subfolders.
robocopy D:\Photos E:\Photos /mirMirrors a folder, deleting extra files.
robocopy D:\Photos E:\Photos /e /zCopies big files, resuming if cut off.
robocopy D:\Photos E:\Photos /e /mt:16Copies with 16 threads, much faster.
robocopy D:\Photos E:\Photos /e /xoSkips files that are older.
Find and compare
find "error" log.txtFinds a word in a file.
findstr /s /i "invoice" *.txtSearches all subfolders, any case.
findstr /n "TODO" app.jsShows matches with line numbers.
fc old.txt new.txtCompares two text files.
fc /b a.jpg b.jpgCompares two files byte by byte.
certutil -hashfile setup.exe SHA256Shows a file's SHA-256 hash.
sort names.txtSorts the lines of a file.
Hidden files and permissions
attrib +h secret.txtHides a file.
attrib -h secret.txtUnhides it.
attrib -h -s -r E:\*.* /s /dUnhides everything on a USB drive.
takeown /f D:\Old /r /d yMakes you the owner of a folder.
icacls D:\OldShows who can open a folder.
icacls D:\Old /reset /tResets a folder's permissions.
mklink /j C:\Games D:\GamesLinks a folder to another drive.
subst X: D:\ProjectsShows a folder as drive X.
subst X: /dRemoves that drive.
forfiles /p D:\Logs /d -30 /c "cmd /c del @path"Deletes files older than 30 days.
Repair and clean up 23
Type in Command PromptWhat it does
Repair Windows
sfc /scannowFinds and fixes broken system files (as admin).
sfc /verifyonlyChecks them without fixing.
DISM /Online /Cleanup-Image /CheckHealthQuick check for a damaged Windows.
DISM /Online /Cleanup-Image /ScanHealthDeeper check. Takes a few minutes.
DISM /Online /Cleanup-Image /RestoreHealthRepairs Windows from Windows Update.
Check the drive
chkdskChecks the drive without fixing.
chkdsk C: /scanScans while you keep working.
chkdsk C: /fFixes errors. Drive C waits for a restart.
chkdsk D: /rAlso finds bad sectors.
fsutil dirty query C:Shows if a check is pending.
Free up space
cleanmgrOpens Disk Cleanup.
cleanmgr /sageset:1Picks what to clean.
cleanmgr /sagerun:1Cleans using those picks.
cleanmgr /verylowdiskCleans with no questions.
del /q /f /s %TEMP%\*Clears your temp files.
DISM /Online /Cleanup-Image /StartComponentCleanupRemoves old update files (as admin).
DISM /Online /Cleanup-Image /StartComponentCleanup /ResetBaseRemoves more, but updates can't be uninstalled.
powercfg /hibernate offTurns off hibernation and frees its space.
Speed up drives
defrag C: /aChecks if a drive needs it.
defrag C: /oOptimizes a drive, HDD or SSD.
defrag /c /oOptimizes every drive.
defrag C: /lRuns TRIM on an SSD.
cipher /w:C:\Wipes deleted files from free space.
Drives and disks 20
Type in Command PromptWhat it does
Drive info
fsutil fsinfo drivesLists every drive letter.
fsutil volume diskfree C:Shows free and used space.
volShows the drive's name and serial.
label E: BackupRenames a drive.
manage-bde -statusShows BitLocker status.
manage-bde -protectors -get C:Shows your BitLocker recovery key.
Format a drive
Formatting erases the drive.
format E: /fs:exfat /qErases a USB drive for any computer.
format E: /fs:ntfs /qErases a drive as NTFS.
Diskpart
Type these after diskpart. Clean erases everything, so check the disk number.
diskpartOpens the disk tool (as admin).
list diskLists your disks.
select disk 1Picks disk 1.
list volumeLists drives and partitions.
list partitionLists the disk's partitions.
attributes disk clear readonlyRemoves write protection.
cleanErases the whole disk.
convert gptMakes an empty disk GPT.
create partition primaryCreates a partition.
format fs=ntfs quick label=BackupFormats it.
assign letter=EGives it a drive letter.
exitLeaves Diskpart.
Network and Wi-Fi 33
Type in Command PromptWhat it does
IP and DNS
ipconfigShows your IP address.
ipconfig /allAdds MAC address, DNS and more.
ipconfig /releaseDrops your IP address.
ipconfig /renewGets a new one.
ipconfig /flushdnsClears the DNS cache.
ipconfig /displaydnsShows the DNS cache.
nslookup techpp.appLooks up a site's IP address.
nslookup techpp.app 1.1.1.1Asks a different DNS server.
Test a connection
ping google.comChecks if a site answers.
ping /t google.comKeeps pinging until Ctrl+C.
ping /n 10 google.comPings 10 times.
tracert google.comShows every hop on the way.
pathping google.comFinds where packets get lost.
Connections and ports
netstat -anoLists connections with process IDs.
netstat -bShows the app behind each one (as admin).
netstat -eShows data sent and received.
arp -aLists devices your PC has seen nearby.
getmacShows MAC addresses.
route printShows the routing table.
Wi-Fi
netsh wlan show profilesLists saved Wi-Fi networks.
netsh wlan show profile name="Home WiFi" key=clearShows a saved Wi-Fi password.
netsh wlan show interfacesShows signal and speed.
netsh wlan show networksLists Wi-Fi networks nearby.
netsh wlan show driversShows what your Wi-Fi card supports.
netsh wlan show wlanreportBuilds a Wi-Fi history report.
netsh wlan connect name="Home WiFi"Joins a saved network.
netsh wlan disconnectLeaves Wi-Fi.
netsh wlan delete profile name="Home WiFi"Forgets a network.
netsh wlan export profile folder=C:\WiFi key=clearBacks up every network with passwords.
Reset the network
netsh winsock resetFixes broken internet. Restart after.
netsh interface ipv4 resetResets IP settings. Restart after.
netsh advfirewall resetResets Windows Firewall rules.
netsh interface ipv4 show interfacesLists network adapters.
System info 34
Type in Command PromptWhat it does
About this PC
systeminfoShows Windows, RAM, install date and more.
systeminfo | findstr /c:"OS Name" /c:"Total Physical Memory"Just the Windows edition and RAM.
hostnameShows the PC's name.
whoamiShows who you are signed in as.
msinfo32Opens System Information.
tpmtool getdeviceinformationShows TPM details.
date /tShows the date.
time /tShows the time.
tzutil /gShows the time zone.
setLists environment variables.
pathShows where Windows looks for programs.
Drivers
driverqueryLists installed drivers.
driverquery /vAdds status and file paths.
pnputil /enum-driversLists added driver packages.
pnputil /enum-devices /problemLists devices with problems.
pnputil /scan-devicesLooks for new hardware.
Running apps
tasklistLists running apps.
tasklist /svcShows services in each one.
tasklist /fi "memusage gt 500000"Apps using over 500 MB.
taskkill /im notepad.exe /fForce closes an app.
taskkill /pid 1234 /fForce closes by process ID.
taskkill /im chrome.exe /t /fCloses an app and all its windows.
Battery and sleep
powercfg /batteryreportBuilds a battery health report.
powercfg /energyFinds power problems (as admin).
powercfg /sleepstudyShows what drained the battery in sleep.
powercfg /requestsShows what is keeping the PC awake.
powercfg /lastwakeShows what woke the PC.
powercfg /devicequery wake_armedLists devices that can wake it.
powercfg /aLists the sleep modes it supports.
Logs
wevtutil qe System /c:10 /rd:true /f:textShows the 10 newest system events.
perfmon /relOpens Reliability Monitor.
perfmon /resOpens Resource Monitor.
perfmon /reportBuilds a 60-second health report.
gpresult /rShows the policies applied to you.
Apps and services 27
Type in Command PromptWhat it does
Install apps with WinGet
winget search powertoysFinds an app.
winget install Microsoft.PowerToysInstalls it.
winget show Microsoft.PowerToysShows details about it.
winget listLists installed apps.
winget upgradeLists apps with updates.
winget upgrade --allUpdates every app.
winget uninstall Microsoft.PowerToysRemoves an app.
winget export -o apps.jsonSaves a list of your apps.
winget import -i apps.jsonInstalls them on a new PC.
Services
net startLists running services.
sc query spoolerShows one service's status.
net stop spoolerStops a service (as admin).
net start spoolerStarts it again.
sc config spooler start= disabledStops it starting with Windows.
sc config spooler start= autoStarts it with Windows again.
Scheduled tasks
schtasks /queryLists scheduled tasks.
schtasks /create /sc daily /tn "Backup" /tr "C:\Scripts\backup.bat" /st 21:00Runs a script every day at 9 PM.
schtasks /run /tn "Backup"Runs a task now.
schtasks /delete /tn "Backup" /fDeletes a task.
Registry
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\RunLists your startup apps.
reg export HKCU\Software\MyApp backup.regBacks up a registry key.
reg import backup.regRestores it.
reg add HKCU\Software\MyApp /v Theme /t REG_SZ /d DarkAdds a value.
reg delete HKCU\Software\MyApp /v Theme /fDeletes a value.
Open Windows tools
mstscOpens Remote Desktop.
mstsc /v:192.168.1.20Connects to a PC by its IP.
assoc .txtShows a file type's name.
Power and users 24
Type in Command PromptWhat it does
Shut down and restart
shutdown /s /t 0Shuts down now.
shutdown /r /t 0Restarts now.
shutdown /s /t 3600Shuts down in one hour.
shutdown /aCancels a timed shutdown.
shutdown /lSigns you out.
shutdown /hHibernates.
shutdown /r /o /t 0Restarts into recovery options.
shutdown /r /fw /t 0Restarts into BIOS or UEFI.
Power plans
powercfg /listLists power plans.
powercfg /getactiveschemeShows the plan in use.
powercfg /change monitor-timeout-ac 5Screen off after 5 minutes plugged in.
powercfg /change standby-timeout-dc 15Sleep after 15 minutes on battery.
powercfg /hibernate onTurns hibernation on.
User accounts
net userLists accounts on this PC.
net user AlexShows one account's details.
net user Alex *Changes its password (as admin).
net user Alex * /addAdds an account.
net user Alex /active:noTurns an account off.
net user Alex /deleteDeletes an account.
net localgroup administratorsLists admins.
net localgroup administrators Alex /addMakes someone an admin.
net accountsShows password rules.
quserLists who is signed in.
cmdkey /listLists saved sign-ins.
Batch files 27
Type in Command PromptWhat it does
Script basics
@echo offHides each command as it runs.
echo HelloPrints text.
rem Daily backupAdds a comment.
pauseWaits for a key press.
timeout /t 10Waits 10 seconds.
timeout /t 10 /nobreakWaits, ignoring key presses.
call other.batRuns another script, then comes back.
start /wait setup.exeRuns a program and waits for it.
exit /b 0Ends the script.
Variables
set name=AlexSets a variable.
echo %name%Uses it.
set /p name=Your name: Asks the user for a value.
set /a total=5+3Does math.
setx MY_FOLDER D:\ProjectsSaves a variable for good.
echo %~dp0The script's own folder.
echo %errorlevel%The last command's exit code.
setlocalKeeps changes inside the script.
endlocalEnds that.
Choices and loops
In a .bat file use %%f. Typed at the prompt it is %f.
if exist notes.txt echo FoundChecks if a file exists.
if "%name%"=="Alex" echo HiCompares text.
if errorlevel 1 echo FailedChecks if the last command failed.
choice /c yn /m "Continue?"Asks Y or N.
goto endJumps to the :end label.
for %%f in (*.txt) do echo %%fLoops over files.
for /l %%i in (1,1,5) do echo %%iCounts from 1 to 5.
for /f "tokens=*" %%a in (list.txt) do echo %%aReads a file line by line.
shiftMoves to the next argument.