Command Prompt (cmd) Flags & Options
The Windows command interpreter, its built-in commands and batch files.All Command Prompt (cmd) pages
- cmd /c vs cmd /k: run a command and exit, or keep the window opencmd /c runs a command and exits with its exit code; cmd /k keeps the window open. Tested: exit codes, chaining with && and &, /v:on and quote-stripping rules.
- robocopy /MIR: mirror a folder (and why it deletes files in the destination)robocopy /MIR mirrors a folder: it copies subfolders and deletes destination files missing from the source. Preview with /L, exit codes 1-3 and /E /PURGE.
- set /p: read user input or the first line of a file in a batch fileset /p VAR=Prompt waits for a line of input and stores it in VAR. With < file it reads the first line. Empty input leaves VAR unchanged and sets errorlevel 1.
- setlocal enabledelayedexpansion: why variables do not change inside a for loopcmd expands %VAR% once per line or parenthesised block, so loops see old values. setlocal enabledelayedexpansion adds !VAR!, which is read each time it runs.