So my batch script is ticking along nicely when suddenly this appears in the output log:
21:27:13.99 c:\\apps\\w7lab-scripting>some-command
Error 32212257
The magic here is in exit code 3221225786, aka 0xC000013A or STATUS_CONTROL_C_EXIT.
The interactive application received a control-C, and didn't catch it, so as expected, it was aborted with STATUS_CONTROL_C_EXIT. The some-command
application correctly reported this as the remote application's exit code, and passed it back to the batch script.
What I hadn't realized was that cmd.exe
detects control-C in a batch script in exactly this way, by checking whether a child process returns STATUS_CONTROL_C_EXIT. So by returning this error code I was inadvertently stopping the batch script.
This can be demonstrated with a simple batch script:
cmd /c exit 3221225786
echo hello
which, when run, produces
C:\working\test>cmd /c exit 3221225786
^CTerminate batch job (Y/N)?