These are STILL_ACTIVE (thread) and STATUS_PENDING (process). Seeing them from GetExitCodeProcess means you called it before the process actually exited. This is a classic race.
Crucially, the exit code is the return value of main() in the C runtime sense. The CRT wraps main() , captures its return value, and passes it to ExitProcess() . If you never call ExitProcess explicitly, the CRT does it for you. exit codes windows
In cmd.exe , the exit code of a batch file is the exit code of the last command executed . A batch file that copies a file and then echoes a message will return 0 even if the copy failed, because echo always succeeds. This forces developers to use exit /b %errorlevel% explicitly. These are STILL_ACTIVE (thread) and STATUS_PENDING (process)
In the seemingly sterile output of a command-line program—a lone integer returned to the operating system—lies a sophisticated, often misunderstood contract between a process and its caller. On Windows, this integer is the exit code (or "return code"), and while the convention 0 for success and non-zero for failure is universal, the depth beneath is uniquely shaped by Windows' architecture, its legacy subsystems, and the perils of cross-platform assumptions. 1. The Kernel's Handshake: How Exit Codes Really Work When a Windows process terminates—whether by returning from main() , calling ExitProcess() , or suffering an unhandled exception—the kernel records a 32-bit unsigned integer inside the EPROCESS block. This value persists until the process object is reaped by WaitForSingleObject() or GetExitCodeProcess() . Crucially, the exit code is the return value
If yes, it's either an NTSTATUS (0xCxxxxxxx) or HRESULT (0x8xxxxxxx). Use the Visual Studio tool err.exe or net helpmsg :
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. 4. The Debugger's Compass: Interpreting Exit Codes as Clues For a systems engineer, an unexpected exit code is a compressed diagnostic. Here’s how to decompress it:
Et nihil atque ex. Reiciendis et rerum ut voluptate. Omnis molestiae nemo est. Ut quis enim rerum quia assumenda repudiandae non cumque qui. Amet repellat omnis ea.
Et nihil atque ex. Reiciendis et rerum ut voluptate. Omnis molestiae nemo est. Ut quis enim rerum quia assumenda repudiandae non cumque qui. Amet repellat omnis ea.