Note "When the process is no longer running". Certainly there's no exit status before the process is terminated, you can't use it while it's running. Wait until terminated (not Running = true) then you have the expected value.
p.Options := [poWaitOnExit];
p.Execute;
DoSomethingWith(p.ExitStatus); // <- there you have it correct
[/quote]
According to the documentation, you can put DoSomethingWith(0); in this example.
Note "If it is not running then the value is zero." -- according to what documentation says, it is
unconditionally zero. So, checking the value doesn't make sense.
Then you most certainly must have overlooked the situation were the command stopped working and you need to know _why_ it stopped working (as in lagprogramming's case).
How can you get the reason why, if the value is always zero, as documentation says?