Summary

This script (written in VBScript) demonstrates how to use the adTempus API to execute a job. The code can be placed in a script library or script within adTempus, or used in a script that runs outside of adTempus.

Note that the user who runs the script (whether it is run as part of an adTempus job or outside of adTempus) must have the necessary permissions to connect to adTempus and to execute the job.

Using the Script in adTempus

To use this script in adTempus, first create a new Script Library that contains the code from the Sample Code section below. Then create a new script that references the Script Library you just created and that calls the RunAdTempusJob function, e.g.:

RunAdTempusJob "MyJobName",-1

Notes

When setting up the script, set the Maximum execution time to "-1" in both the Script Properties and Script Execution Task windows.

This function submits an execution command to the server; it does not wait while the job executes. It returns a success result as long as the execution request is submitted. This does not guarantee that the job will be started successfully.

Sample Code

'Runs an adTempus job, given the job's name.
'The Options specify execution options (equivalent to the options available in the Run Job dialog in the Console). 
'See the adTempus API documentation for information on the options.
'If set to -1, the options default to eoIgnoreHeld (run even if held) + eoRunOnAgents (runs on agents if appropriate)
function RunAdTempusJob(jobName,options)
Dim app
Dim session
Dim jobs
Dim job
Dim i
        RunAdTempusJob=False
        
        if options = -1 then
                options=&h18    'eoIgnoreHeld (&h8) + eoRunOnAgents (&h10)
        end if
        'Create the adTempus Application object 
        Set app = CreateObject("adtempus.Application")
        
        'Create a new session, using "implicit" Windows security for authentication
        Set session = app.Connect("", "")   
        
        Set jobs = session.GetObjectsForClass(1)  'get all the jobs
        For i = 1 To jobs.Count
                'go through the jobs to find the one we want
                Set job = jobs(i)
                if job.name=jobName then
                        job.Execute(options)
                        RunAdTempusJob=True
                        exit for
                end if
        Next
        
        set job=nothing
        set session=nothing
        set app=nothing
        
end function

More Information

For more information on the adTempus API, see the API documentation.