问题
Our server has MANY tasks in Task Scheduler that run on varying schedules. I need to be notified by email only when one particular tasks completes. Seeing that the appropriate Event ID for a successfully completed task is 102, I was able to create an event that would email me whenever any task completed, ensuring that my emailing action is properly configured. My problem comes into play when I'm trying to get this email to be triggered for my task called 'Email Parser' ONLY, and I believe I need a custom trigger for this to happen.
What I've done:
In my emailing event's Triggers tab, I selected to begin the task 'On an event,' selected the 'Custom' radio box, and selected to 'Edit Event Filter.'
I selected 'By Source' and chose 'TaskScheduler' from the dropdown. Where the textbox read '<All Event IDs>
', I changed this to 102. For simplicity, I left everything else the same for now.
The XML tab automatically populated the following:
<QueryList>
<Query Id="0" Path="Microsoft-Windows-TaskScheduler/Debug">
<Select Path="Microsoft-Windows-TaskScheduler/Debug">*[System[Provider[@Name='Microsoft-Windows-TaskScheduler'] and (EventID=102)]]</Select>
<Select Path="Microsoft-Windows-TaskScheduler/Diagnostic">*[System[Provider[@Name='Microsoft-Windows-TaskScheduler'] and (EventID=102)]]</Select>
<Select Path="Microsoft-Windows-TaskScheduler/Operational">*[System[Provider[@Name='Microsoft-Windows-TaskScheduler'] and (EventID=102)]]</Select>
<Select Path="System">*[System[Provider[@Name='Microsoft-Windows-TaskScheduler'] and (EventID=102)]]</Select>
</Query>
</QueryList>
When I click OK and try to confirm these changes, I get a popup saying 'Error message: The following error was reported: The request is not supported..'
Upon researching more on custom triggers, I found http://www.thegreenbutton.tv/forums/viewtopic.php?f=22&t=4948 to be a clear reference to creating the proper XML for a custom trigger.
Following these instructions, I constructed the following:
<QueryList>
<Query Id="0" Path="System">
<Select Path="System">
*[System[Provider[@Name='Microsoft-Windows-TaskScheduler'] and (EventID=102)]]
and
*[EventData[Data[@Name='TaskName'] and (Data='Email Parser')]]
</Select>
</Query>
</QueryList>
When I click OK and enter my password to confirm, Task Scheduler seems to accept these arguments for the trigger, but the event never triggers! I am able to manually tell this event to Run without issue. The problem lies within my trigger, but I need another set of eyes to tell me what I'm missing.
The relevant Details that I referenced from my Email Parser task's History tab are below:
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name="Microsoft-Windows-TaskScheduler" Guid="{de7b24ea-73c8-4a09-985d-5bdadcfa9017}" />
<EventID>102</EventID>
<Version>0</Version>
<Level>4</Level>
<Task>102</Task>
<Keywords>0x8000000000000000</Keywords>
<Channel>Microsoft-Windows-TaskScheduler/Operational</Channel>
</System>
- <EventData Name="TaskSuccessEvent">
<Data Name="TaskName">\Email Parser</Data>
</EventData>
</Event>
Thank you in advance for any assistance!
来源:https://stackoverflow.com/questions/32206721/task-scheduler-custom-event-filter-trigger-is-not-triggering-action