Exit Codes Windows [verified] Jun 2026
Any exit code that isn't zero—, 2 , -1 , 87 , 1603 —is a scream for help. It means, "Something went wrong." But in the hands of a lazy developer, a non-zero exit code can be misinterpreted by the operating system as a command, or worse, be ignored entirely.
When working with exit codes:
PowerShell-native commands return rich objects, not exit codes. When you run an external .exe , PowerShell captures its exit code in $LASTEXITCODE , but the PowerShell process's own exit code is set only by exit $n . A script that runs non-existent.exe will see $LASTEXITCODE = 0xC0000135 (STATUS_DLL_NOT_FOUND), but the PowerShell process itself exits with 0 unless you explicitly forward it. exit codes windows
It was a simple integer, a single 32-bit number passed from one process to another. But in the dark, silent logic of the operating system, that number was the difference between a functioning system and a broken loop. It was the difference between Success and Failure . Any exit code that isn't zero—, 2 ,
Elias sat back as the success message pinged his monitoring dashboard. When you run an external
> net helpmsg 2 The system cannot find the file specified.