Exit Codes

adTempus does not know what, if anything, a particular exit code from your program means. It only reports the information it receives from the program, and responds according to the rules you have defined.

The meaningif any—is determined by whoever wrote the program.

Whenever a program runs, it passes a numeric exit code (or return code) back to the operating system (or in this case adTempus) to indicate its status.

While all programs return an exit code, not all programs return a meaningful exit code.

By convention, programs return a value of 0 to indicate successful completion or some value greater than 0 to indicate a warning or error condition.

Generally, programs that were designed to be run in a batch fashion will return some sort of useful exit code. This value can be used by adTempus to determine the success or failure of the task (see the success criteria for the Program Execution task).

adTempus does not know what the exit codes from a particular program mean, if anything. Check the documentation for the application in question, or check with its maker.

Remember, it's entirely possible that the exit code is meaningless. adTempus defaults to treating anything other than 0 as a failure, because that's the convention. If you program appears to be working properly but keeps sending back an exit code of 42, you can change the success criteria for the step so that adTempus won't fail it.

How to Set the Exit Code

How you set the exit code depends on what development language you're setting it from.

C/C++ Programs

The exit code is the return value from the main() or WinMain function.

Visual Basic

If you are using Visual Basic .NET, you need a main function that returns a value; that's the exit code. See the VB.NET documentation for details.

If you are using an earlier version of VB, there is no supported method for returning an exit code. Microsoft used to recommend the approach described below. We give it to you here for your convenience, but please be aware that they no longer recommend or support this approach, due to the problems described in their knowledge base article Q288216. If you choose to use this approach do not complain to us or them if it causes problems; you've been warned. Show me how.

This approach uses the Windows API ExitProcess function to terminate the VB program, returning an exit code. Please read this before you use this method. Now here's the code:

Private Declare Sub ExitProcess Lib "kernel32" (ByVal exitCode As Long)

ExitProcess(42)

Replacing, of course, 42 with whatever exit code you want to return.

In addition to the problems noted by Microsoft, we'll point out that calling the ExitProcess function while your program is being debugged in the Visual Basic development environment will cause the Visual Basic IDE itself to terminate, along with your program.

A better approach would be to a) use something other than VB, or use a newer version of VB or b) use a file to signal success. You can then use a script to check for the presence of this file and set the step's status accordingly.

Batch Files

The exit code from a batch file is the exit code of the last process the batch file executed. If you want to set the exit code of your batch file to something in particular, you'll find a program called "exitcode" in the adTempus program directory. It does nothing except exit immediately with the exit code set to whatever you pass it on the command line. Call this program with the desired exit code and end your batch file right afterward and the batch file will have the desired exit code. For example:

exitcode 42

Sets the exit code to 42.

Scripts

If you're using a Script Execution task to run the script you can return an exit code as described here. If you're executing the script in some other fashion (e.g., using wscript within your batch file) you're out of luck.

Everything Else

Check the documentation for whatever development language you're using.