Skip to content

Instantly share code, notes, and snippets.

@jreypo
Last active September 18, 2025 08:37
Show Gist options
  • Select an option

  • Save jreypo/08533bc50da17944cc8f413962d437a2 to your computer and use it in GitHub Desktop.

Select an option

Save jreypo/08533bc50da17944cc8f413962d437a2 to your computer and use it in GitHub Desktop.

CMD useful comands

  • tasklist - To list the tasks running
  • taskkill - To kill a task

Examples

Search for a task

C:\>tasklist | find /i "notepad"
notepad.exe                  23512 Console                    2     16,304 K

Kill a task based on its image name.

C:\>taskkill /im notepad.exe
SUCCESS: Sent termination signal to the process "notepad.exe" with PID 23512.

Search for a port and PID of the task associated with it.

C:\>netstat -aon | find /i "192.168.1.34:62583"
  TCP    192.168.1.34:62583     168.62.106.216:443     ESTABLISHED     17404

More commands

File & Directory Management

  • dir – Lists files and folders in the current directory
  • cd – Displays or changes the current directory
  • md / mkdir – Creates a new directory
  • rd / rmdir – Removes a directory (use /S for contents)
  • del – Deletes one or more files
  • copy – Copies files from one location to another
  • xcopy – Advanced file copy, supports directories
  • robocopy – Robust file copy (mirroring, retries)
  • move – Moves or renames files
  • ren – Renames a file or folder
  • attrib – Displays or changes file attributes
  • type – Displays the contents of a text file
  • more – Displays text one screen at a time
  • tree – Graphically displays folder structure

System Information

  • ver – Displays Windows version
  • systeminfo – Detailed system configuration and OS info
  • hostname – Displays computer name
  • set – Shows environment variables
  • echo – Displays text or variables
  • date – Displays or sets system date
  • time – Displays or sets system time

Disk & File System

  • chkdsk – Checks disk for errors
  • diskpart – Opens disk partition utility
  • format – Formats a disk for use
  • label – Changes volume label of a disk
  • vol – Displays disk volume label and serial number
  • fsutil – Advanced file system utility
  • mountvol – Manages volume mount points
  • compact – Displays/changes NTFS compression
  • cipher – Manages NTFS encryption

Networking

  • ping – Tests network connectivity to a host
  • tracert – Traces route packets take to a destination
  • ipconfig – Displays IP configuration info
  • netstat – Displays active network connections
  • nslookup – Queries DNS servers for name resolution
  • arp – Displays/edits ARP table
  • net use – Manages shared network drives
  • net user – Manages user accounts
  • net share – Manages shared folders
  • net view – Shows shared resources on a computer
  • net session – Displays/disconnects sessions
  • netsh – Configures network stack (firewall, TCP/IP, etc.)
  • pathping – Combines ping + tracert with loss statistics
  • nbtstat – Displays NetBIOS over TCP/IP info
  • getmac – Displays MAC addresses

Process & Task Management

  • tasklist – Lists running processes
  • taskkill – Kills processes by name or PID
  • shutdown – Shuts down, restarts, or logs off computer
  • logoff – Logs off the current user
  • cls – Clears the screen
  • pause – Pauses batch file execution
  • schtasks – Manages scheduled tasks

Scripting & Utilities

  • call – Calls another batch file
  • exit – Closes the command prompt window
  • help – Lists available commands
  • find – Searches for text in files
  • fc – Compares two files and shows differences
  • where – Locates a file in the PATH
  • choice – Prompts user for a choice (batch scripts)
  • for – Iterates over items in a batch script
  • if – Conditional execution in scripts
  • goto – Jumps to a label in batch files
  • shift – Shifts batch arguments
  • setlocal / endlocal – Controls environment variable scope
  • assoc – Displays or modifies file associations
  • ftype – Defines executables for file types
  • pushd / popd – Saves/restores current directory

Administrative & System

  • sfc – Scans and repairs Windows system files
  • dism – Manages Windows images and drivers
  • bcdedit – Edits boot configuration data
  • sc – Service Controller for Windows services
  • reg – Registry editor via command line
  • driverquery – Lists installed drivers
  • gpupdate – Applies group policy updates immediately
  • gpresult – Displays group policy results
  • whoami – Displays current user and groups

Less-Known / Hidden

  • clip – Redirects output to clipboard
  • msg – Sends popup messages to network users
  • start – Opens files, folders, or programs
  • explorer – Opens File Explorer
  • control – Opens Control Panel or applets
  • taskmgr – Opens Task Manager
  • mstsc – Opens Remote Desktop Connection
  • dxdiag – DirectX Diagnostic Tool
  • perfmon – Performance Monitor
  • lodctr / unlodctr – Loads/unloads performance counters
  • rasdial – Manages dial-up or VPN connections
  • klist – Displays Kerberos tickets
  • debug – Old DOS debugger (legacy, removed in x64 Windows)
  • edlin – Line editor from DOS (legacy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment