CMD Troubleshooting
Cheat sheet · https://pcornel.dk/topic.php?topic=3059
Answer
Troubleshoot cmd and batch scripts with echo on, checking %ERRORLEVEL% after each command, quoting paths with spaces, enabling delayed expansion (!var!) inside loops and running as the right user or elevated.
Remember
- Unquoted paths with spaces break commands.
- %var% inside a block expands once when the block is parsed.
- Some commands need an elevated prompt.
First checks
echo %PATH%— PATH in CMDset— environment variableswhere <name>— command resolutionecho %ERRORLEVEL%— exit code
Verify in this order
line parsed → expansion → command resolution → execution → error code
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=3059