1

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>
0

Found an easy way to cover all scenarios for error and critical messages.

<QueryList>
  <Query Id="0" Path="Microsoft-Windows-TaskScheduler/Operational">
    <Select Path="Microsoft-Windows-TaskScheduler/Operational">

    *[
        System
        [
            Provider[@Name='Microsoft-Windows-TaskScheduler'] 
            and (Level=1 or Level=2)
        ]       
    ]

        and

    *[
        EventData
        [
            Data
            [
                @Name='TaskName'
            ]='\Tasks\test'
        ]
    ]    

    </Select>
  </Query>
</QueryList>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.