Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

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>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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