Menu

List of Command Prompt commands

Type a task or command name to narrow the list. Select a command to open a detailed article with options and examples.

67 commands

Files and folders

Command What it does Example
assoc / ftype View and change file associations
assoc .txt
attrib Change read-only and hidden attributes
attrib +r file.txt
cd / chdir Change the current directory
cd /d D:\work
copy Copy or combine files
copy a.txt D:\backup\
del / erase Delete files
del /q *.tmp
dir List files and folders
dir /s /b *.txt
forfiles Run a command on files that match conditions
forfiles /m *.log /d -30 /c "cmd /c del @path"
icacls View and change access permissions
icacls C:\data
mklink Create symbolic links
mklink /d link target
move Move or rename files and folders
move a.txt D:\backup\
pushd / popd Change directory and return to it later
pushd \\server\share
rd / rmdir Delete folders
rmdir /s /q old
robocopy Copy and sync large folder trees
robocopy src dst /e
subst Map a folder to a drive letter
subst X: C:\work
tar Create and extract archives such as ZIP
tar -xf archive.zip
tree Show the folder structure as a tree
tree /f > tree.txt
where Find where an executable is located
where python
xcopy Copy folders including their contents
xcopy src dst /s /e /i

Text and output

Command What it does Example
certutil Calculate file hashes and encode/decode Base64
certutil -hashfile file.zip SHA256
chcp Switch the code page (fix garbled text)
chcp 65001
clip Copy output to the clipboard
ipconfig | clip
echo Display text or write it to a file
echo Hello > out.txt
fc Compare two files
fc a.txt b.txt
find Search for text in files
find "error" log.txt
findstr Search text with regular expressions across files
findstr /s /i "error" *.log
more Show long output one screen at a time
type log.txt | more
sort Sort lines of text
sort list.txt /o sorted.txt
type Display the contents of a text file
type log.txt

Batch file control

Command What it does Example
call Call another batch file or subroutine and return
call sub.bat
choice Let the user choose with a key press
choice /c YN
cmd Start a new instance of the command interpreter
cmd /c dir
exit Exit a batch file or Command Prompt
exit /b 1
for Loop over files and values
for %i in (*.txt) do echo %i
goto Jump to a label
goto :eof
if Run commands conditionally
if exist file.txt echo OK
pause Wait until a key is pressed
pause
rem Add comments or comment out lines
rem comment
setlocal / endlocal Limit the scope of variables
setlocal enabledelayedexpansion
start Launch a program in a separate window
start "" notepad.exe
timeout Wait for a number of seconds
timeout /t 5

Console window

Command What it does Example
cls Clear the screen
cls
color / title Change colors and the window title
color 0a
doskey Use command history and aliases
doskey /history
mode Change the window size and other settings
mode con cols=120 lines=40

Network

Command What it does Example
arp Show IP-to-MAC address mappings
arp -a
curl Download and send data over HTTP
curl -O https://example.com/file.zip
ipconfig Check IP address and network settings
ipconfig /all
net Manage network drives, users and shares
net use
netsh View and change Wi-Fi, firewall and other settings
netsh wlan show profiles
netstat Show connections and ports in use
netstat -ano
nslookup Look up DNS records
nslookup example.com
ping Check whether a host is reachable
ping example.com
tracert Trace the network route
tracert example.com

System, processes and settings

Command What it does Example
powercfg Check power settings and battery health
powercfg /batteryreport
reg Read and edit the registry
reg query HKCU\Environment
sc Query, start and stop services
sc query
schtasks Create and view scheduled tasks
schtasks /query
shutdown Shut down or restart the PC
shutdown /s /t 60
systeminfo Show OS and hardware information
systeminfo
taskkill Terminate processes
taskkill /im notepad.exe /f
tasklist List running processes
tasklist /fi "imagename eq notepad.exe"
whoami Show the current user and privileges
whoami /priv
winget Install and update apps
winget upgrade --all

Disks and repair

Command What it does Example
chkdsk Check and repair disk errors
chkdsk C:
diskpart Manage disks and partitions
diskpart
fsutil Inspect the file system and create dummy files
fsutil volume diskfree C:
sfc / DISM Repair corrupted system files
sfc /scannow