Thank you very much for the example script, this was exactly what i needed.
I found a (free) Active-X DLL for writing to the eventlog. I combined that script, and yours into a "shared script" in adTempus. Then I call that script from a response, and that's it.
Here is the script for anyone who need the same:
' By: Azathoth
' Version: 1.0
' Last update: 02/06/2005
' Description: Writes the failed adTempus jobs to the eventlog.
'
' This script uses the (free) STMAdmin.dll to write to the eventlog.
' You can download it here:
' http://cwashington.netreach.net/downloads/com/event_log_manager.zip
' Constants for Event Logging
Const EVENT_SUCCESS = 0
Const EVENT_ERROR = 1
Const EVENT_WARNING = 2
Const EVENT_INFORMATION = 4
' Declarables
Dim objAdTempus
Dim objSession
Dim objJob
Dim strJobName
Dim intJobStatus
Dim objEventLog
Dim intEventID
Dim blnError
Dim strGroupName
Dim strGroupDescription
' Create the adTempus Application object
set objAdTempus = CreateObject("adtempus.Application")
' Create a new objSession to the local adTempus server
set objSession = objAdTempus.Connect("","")
' Get the current job
set objJob = objSession.getobject(Environment("ADTJobOID"))
strJobName = objJob.name
' Get the status code for the job. See intJobStatusEnum in the adTempus API reference for a list of values
intJobStatus = objJob.GetStatus.Status
' Get the Group name
strGroupName = objJob.Group.Name
strGroupDescription = objJob.Group.Description
' Default assume it' s an error
blnError = True
Select Case intJobStatus
Case &h80000001
' No Error
blnError = False
strintJobStatus = "The job or step completed successfully."
Case &H40000002
strintJobStatus = "The step was killed because it exceeded its maximum run time."
Case &h50001
strintJobStatus = "The job or step was aborted by a user or JobControlTask."
Case &h40010001
strintJobStatus = "The trigger could not be evaluated."
Case &h40040001
strintJobStatus = "The step failed the task could not be executed (e.g., a program could not be executed)."
Case &h40030001
strintJobStatus = "The job or step failed because a resource failed."
Case &h40020001
strintJobStatus = "The job or step failed because a condition failed."
Case &h40000001
strintJobStatus = "The job or step failed."
Case &h30030001
strintJobStatus = "The job or step is waiting for one or more resources to be available."
Case &h30020001
strintJobStatus = "The job or step is waiting for one or more conditions to be satisfied."
Case &h20050001
strintJobStatus = "The job or step is being aborted."
Case &h20000003
strintJobStatus = "The step is in the process of killing its process because it has exceeded its run time."
Case &h20000002
strintJobStatus = "The job or step is running."
Case &h20000001
strintJobStatus = "The job or step is starting."
Case &h10040001
strintJobStatus = "The job is waiting for a previous instance to finish."
Case &h10010001
strintJobStatus = "The job is waiting for a trigger."
Case &h5
strintJobStatus = "One or more conditions was not met."
Case &h4
strintJobStatus = "The job or step was skipped."
Case &h2
strintJobStatus = "The job or step was abandoned (because adTempus shut down while job was executing)."
Case &h1
strintJobStatus = "The step was not run."
Case &h0
strintJobStatus = "Status unknown, or has never been run."
Case Else
strintJobStatus = "Status unknown: " & intJobStatus
End Select
' Is it an error?
If blnError Then
Set objEventLog = CreateObject("STMAdmin.EventLog")
objEventLog.ReportEvent "adTempus", 1001, vbcrlf & vbcrlf & "Status: The job " & chr(34) & strJobName & chr(34) & " failed." & vbcrlf & "Reason: " & strintJobStatus & vbcrlf & "Group Name: " & strGroupName & vbcrlf & "Group Description: " & strGroupDescription, EVENT_ERROR
' Else
' Set objEventLog = CreateObject("STMAdmin.EventLog")
' objEventLog.ReportEvent "adTempus", 1000, "Status: The job" & chr(34) & strJobName & chr(34) & " completed successfully" & vbcrlf & "Group Name: " & strGroupName & vbcrlf & "Group Description: " & strGroupDescription, EVENT_SUCCESS
End if
Azathoth38505.3250578704