These are actually two separate questions, but ... The exit code is the value returned from the main function of the program. So:
public static int Main() {
It will return an exit code of 0. If the previous // code does not do something else.
Use the Process' ExitCode property to get this value from the application to execute.
0 usually returns when the program terminates successfully. Everything else is a failure, but it is a matter of interpretation.
source share