| |
Manukon
Posts: 3
Score: 0
Joined: 5/7/2008
Status: offline
|
I tried to run the following script. It shows an error "ACTIVEX cannot create object" '------------------------------------------------ ' This sample schedules a task to show ' a message box when an event occurs. '------------------------------------------------ ' A constant that specifies an event trigger. const TriggerTypeEvent = 0 ' A constant that specifies a message box action. const ActionTypeShowMessage = 7 '******************************************************** ' Create the TaskService object. Set service = CreateObject("Schedule.Service") call service.Connect() '******************************************************** ' Get a folder to create a task definition in. Dim rootFolder Set rootFolder = service.GetFolder("\") ' The taskDefinition variable is the TaskDefinition object. Dim taskDefinition ' The flags parameter is 0 because it is not supported. Set taskDefinition = service.NewTask(0) '******************************************************** ' Define information about the task. ' Set the registration info for the task by ' creating the RegistrationInfo object. Dim regInfo Set regInfo = taskDefinition.RegistrationInfo regInfo.Description = "Show a message box when an event occurs." regInfo.Author = "Author Name" ' Set the task setting info for the Task Scheduler by ' creating a TaskSettings object. Dim settings Set settings = taskDefinition.Settings settings.StartWhenAvailable = True '******************************************************** ' Create an event trigger. Dim triggers Set triggers = taskDefinition.Triggers Dim trigger Set trigger = triggers.Create(TriggerTypeEvent) ' Trigger variables that define when the trigger is active. Dim startTime, endTime startTime = "2006-02-28T10:49:02" endTime = "2007-05-02T10:52:02" WScript.Echo "startTime :" & startTime WScript.Echo "endTime :" & endTime trigger.StartBoundary = startTime trigger.EndBoundary = endTime trigger.ExecutionTimeLimit = "PT50M" 'Fifty minutes trigger.Id = "EventTriggerId" ' Define the event query. The trigger will start the task ' when an event is received. trigger.Subscription = "<QueryList> " & _ "<Query Id='1'> " & _ "<Select Path='System'>*[System/Level=4]</Select>" & _ "</Query></QueryList>" Dim valueQueries Set valueQueries = trigger.ValueQueries call valueQueries.Create( _ "eventID", "Event/System/EventRecordID") '*********************************************************** ' Create the action for the task to execute. ' Add an action to the task. The action shows a message box. Dim Action Set Action = taskDefinition.Actions.Create(ActionTypeShowMessage) Action.MessageBody = "This is the event ID: $(eventID)" Action.Title = "Message Box Title" WScript.Echo "Task definition created with an event trigger and message box action." '*********************************************************** ' Register (create) the task. call rootFolder.RegisterTaskDefinition( _ "Test Event Trigger", taskDefinition, 6, _ , , 3) WScript.Echo "Task submitted." WScript.Echo "A message box will appear when " _ & "a level 4 event is logged in the System event log." Can anyone tell me what can be the possible cause(s) for this error? I must admit that I have not done any thorough search on this.
|
|