This guide covers essential legacy command-line tools available in the Windows Command Prompt (cmd.exe).
Each tool is introduced with a basic example, then followed by more advanced usage and real‑world scenarios.
Basic – show files in current folder
dirProgressive – show only directories, wide format, including hidden/system files
dir /A:D /W
dir /A:H /S (find hidden files in all subfolders)Basic – go to C:\Windows
cd C:\WindowsProgressive – go up two levels, then down to Users\Public
cd ..\..\Users\PublicclsBasic – copy one file to another location
copy report.txt D:\Backup\Progressive – concatenate multiple text files into one
copy file1.txt + file2.txt combined.txtBasic – copy all files and subfolders (/E), preserving read‑only attribute (/K)
xcopy C:\Data D:\DataBackup /E /KProgressive – copy only files modified after a certain date, with verification
xcopy "C:\Users\Public\*.docx" D:\Archive /D:01-01-2025 /VBasic – move old.txt into Archive\
move old.txt Archive\Progressive – rename a folder (both source and destination paths can be directories)
move "Project X" "Project_X_2025"Basic – delete all .tmp files quietly
del *.tmp /QProgressive – delete files recursively, prompting for each one
del /S /P *.logBasic – create Backup inside Logs
mkdir Logs\BackupBasic – remove empty folder
rmdir OldEmptyFolderProgressive – remove a non‑empty folder and all its contents (/S), without confirmation (/Q)
rmdir /S /Q TempDataBasic – show readme.txt
type readme.txtProgressive – use with more to paginate long files
type longfile.txt | moreBasic – find lines containing “Error” in app.log
find "Error" app.logProgressive – search case‑insensitively (/I) and display line numbers (/N) across multiple files
find /I /N "warning" *.logBasic – ASCII comparison
fc old_config.ini new_config.iniProgressive – binary comparison (/B) for non‑text files
fc /B image1.jpg image2.jpgBasic – make a file hidden and read‑only
attrib +h +r secret.txtProgressive – recursively remove the “system” attribute from all files in a folder
attrib -s C:\Windows\Temp\*.* /SBasic – check drive C: (read‑only)
chkdsk C:Progressive – fix errors (/F), locate bad sectors (/R), and force dismount if needed (/X)
chkdsk C: /F /R /XNote:
/Rimplies/F. The drive may need to be dismounted – answerYto run at next reboot.
Basic – verify and repair protected system files
sfc /scannowProgressive – verify only (no repair) and write logs to a custom path
sfc /verifyonly
sfc /scanfile=C:\Windows\System32\kernel32.dllBasic – show all adapters’ IP, subnet mask, default gateway
ipconfig /allProgressive – release and renew DHCP lease, then flush DNS cache
ipconfig /release
ipconfig /renew
ipconfig /flushdnsBasic – send 4 ICMP packets to google.com
ping google.comProgressive – ping continuously (-t), with 1500 byte packets (-l), stop after 10 pings
ping -t -l 1500 8.8.8.8Stop with Ctrl+C.
Basic – trace hops to example.com
tracert example.comProgressive – avoid hostname resolution (-d) and use a specific timeout per hop
tracert -d -w 1000 192.168.1.1Basic – show all active TCP connections and listening ports numerically (-an)
netstat -anProgressive – show process IDs (-o) and refresh every 5 seconds
netstat -ano 5Then use taskkill (see next section) to close a connection’s owning process.
Basic – show all processes with PID, memory usage
tasklistProgressive – filter only notepad.exe instances and show detailed modules (-m)
tasklist /fi "imagename eq notepad.exe" /mBasic – end a process by PID (ask nicely, then force)
taskkill /PID 1234
taskkill /PID 1234 /FProgressive – kill all processes that match a name (e.g., all calc.exe)
taskkill /IM calc.exe /FBasic – restart after 60 seconds with a comment
shutdown /r /t 60 /c "Scheduled restart"Progressive – abort a pending shutdown, then perform an immediate shutdown
shutdown /a
shutdown /s /t 0Basic – display everything (OS version, manufacturer, uptime, hotfixes)
systeminfoProgressive – filter for specific values using findstr
systeminfo | findstr /i "boot" (find boot time)
systeminfo | findstr /i "hotfix" (list installed updates)Basic – print “Hello World”
echo Hello WorldProgressive – turn off command echoing in a batch file (use @echo off) and create an empty file
@echo off
echo. > empty.txtBasic – show all variables
setProgressive – create a temporary variable and use it in a path
set MYDIR=C:\Temp\Work
mkdir %MYDIR%
copy %USERPROFILE%\*.txt %MYDIR%Basic – list all available commands
helpProgressive – get detailed syntax for xcopy
help xcopy(Alternative: xcopy /? works for most commands.)
The following script demonstrates several tools together:
- Check disk health,
- Copy logs,
- Kill a stuck process,
- Restart the machine if needed.
@echo off
echo === Starting maintenance ===
:: 1. Check disk C: (read-only)
chkdsk C:
:: 2. Find any "crash" entries in system logs
find /I "crash" C:\Windows\Logs\System.log
:: 3. Kill any hanging notepad processes
taskkill /IM notepad.exe /F >nul 2>&1
:: 4. Backup current user's documents to D:\Backup
xcopy "%USERPROFILE%\Documents\*" D:\Backup /E /Y /Q
:: 5. Ask user to restart
set /p answer="Restart now? (Y/N): "
if /i "%answer%"=="Y" shutdown /r /t 10 /c "Restart after maintenance"
echo === Maintenance complete ===Save as maintenance.cmd and run as Administrator for full effect.
| Tool | Basic Task | Progressive Example |
|---|---|---|
dir |
List files | dir /A:D /S – list all folders recursively |
xcopy |
Copy folders | xcopy src dst /E /K /D:01-01-2025 – copy newer files |
fc |
Compare files | fc /B file1.bin file2.bin – binary compare |
attrib |
Change file attributes | attrib +h +r *.* /S – hide & protect all files in tree |
chkdsk |
Check disk | chkdsk C: /F /R – fix errors and scan bad sectors |
ipconfig |
Show IP | ipconfig /release && ipconfig /renew |
ping |
Test host | ping -t 8.8.8.8 – continuous ping |
tracert |
Trace route | tracert -d example.com – fast trace without DNS |
netstat |
Show connections | netstat -ano 5 – live update with PIDs |
taskkill |
Kill process | taskkill /IM virus.exe /F |
shutdown |
Restart PC | shutdown /r /t 0 – immediate restart |
systeminfo |
System details | systeminfo | findstr "OS Name" |
set |
Manage variables | set TEMP=C:\FastTemp – change temp folder for session |
help |
Command help | help copy |
- Use
command /?for built‑in documentation of any tool. - Most tools accept redirection:
dir > filelist.txt,find "text" < input.txt. - These commands are still fully functional on Windows 10/11, though PowerShell offers more power.
For scripting on modern Windows, consider PowerShell – but the classics remain lightweight and omnipresent.
Keep this guide handy – you now have a progressive reference from simple commands to batch automation.