Batch Files
Cheat sheet · https://pcornel.dk/topic.php?topic=3058
Answer
Batch files (.bat or .cmd) are scripts of cmd commands with variables, IF, FOR loops, GOTO and CALL. They suit simple automation; use PowerShell for anything more complex.
Remember
- Use setlocal EnableDelayedExpansion and !var! inside loops.
- Check %ERRORLEVEL% after each important command.
- Quote every path that may contain spaces.
First checks
echo %PATH%— PATH in CMDset— environment variableswhere <name>— command resolutionecho %ERRORLEVEL%— exit codecmd /c script.bat— run a batch file and return
Verify in this order
batch file read line by line → variables expanded → commands run → exit /b 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=3058