Windows Server 2008 Task Scheduler: Task Started (Task=100) but did task did not complete (Task=102) when the result code is 2
- by MacGyver
Can someone give me a use case for setting up a Windows Server 2008 Task Scheduler task (we'll call this "test") that completes (action completed is task=201) with an error (result code=2)? This is event trigger code for another task (called "notification" that sends out an email based on the event history of the "test" task.
I've got use cases for tasks that opens a program successfully and when a program fails to find the program. I'm just trying to think of how I can test a scenario when it finds the program, but something fails with warnings or errors.
/* Failed - task started but had errors (result code of 2) */
<QueryList>
<Query Id="0" Path="Microsoft-Windows-TaskScheduler/Operational">
<Select Path="Microsoft-Windows-TaskScheduler/Operational">
*[
System
[
Provider[@Name='Microsoft-Windows-TaskScheduler']
and (Level=0 or Level=1 or Level=2 or Level=3 or Level=4 or Level=5) and (Task = 201)
]
]
and
*[
EventData
[
Data
[
@Name='TaskName'
]='\Tasks\test'
]
]
and
*[
EventData
[
Data
[
@Name='ResultCode'
]='2'
]
]
</Select>
</Query>
</QueryList>