Pcornel
Windows

Command Prompt

Cheat sheet · https://pcornel.dk/topic.php?topic=3054

Back to the Topic

Answer

Command Prompt (cmd.exe) is the classic Windows command-line shell for built-in commands, batch files, environment variables, pipes and redirection. PowerShell is the more capable modern shell.

Remember

  • cmd passes text, PowerShell passes objects.
  • %ERRORLEVEL% only reflects the last command.
  • Quote paths with spaces.

First checks

  • echo %PATH% — PATH in CMD
  • set — environment variables
  • where <name> — command resolution
  • echo %ERRORLEVEL% — exit code

Commands

cmd.exe
Start the Windows Command Prompt.
FOR
Loop over files or values in a Command Prompt script.
IF
Conditional statement in a Command Prompt script.
SET
Display or set environment variables in Command Prompt.
ping
tracert
nslookup

Verify in this order

cmd.exe parses the line → expands %vars% → finds the command → runs → ERRORLEVEL set

Where it usually breaks

First mismatch in definition/configuration → security context → service/task/process creation → runtime state → output/side effect → event/performance evidence; preserve identity/native error/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=3054

Confirmation

Confirm action

Continue?