Task Scheduler 自定义触发器 - 当 EventID 为 FOO 且 EventData.Data 为 BAR 时启动

Task Scheduler custom trigger - start when EventID is FOO and EventData.Data is BAR

我想 Windows 任务计划程序在特殊事件记录到 Windows 事件日志时启动自定义任务。该事件的 EventID 6702 并且数据参数为 MyBackupJob。这是我当前的自定义触发器,它不起作用:

<QueryList>
  <Query Id="0" Path="VisualSVNServerBackgroundJobs">
    <Select Path="VisualSVNServerBackgroundJobs">
            *[System[(EventID=6702)]] and *[EventData[Data[1]='MyBackupJob']]
    </Select>
  </Query>
</QueryList>

怎么了?

这是日志中的事件示例:

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="VisualSVN Background Job Service" /> 
  <EventID Qualifiers="49152">6702</EventID> 
  <Level>2</Level> 
  <Task>0</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2020-05-11T12:53:34.650971500Z" /> 
  <EventRecordID>4885</EventRecordID> 
  <Channel>VisualSVNServerBackgroundJobs</Channel> 
  <Computer>svn1.example.com</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>{516B8AED-C3CF-4221-BC91-10B18BD3A56F}</Data> 
  <Data>MyBackupJob</Data> 
  <Data>{E3831378-33E1-4C8E-BE8A-CF08DB1CB7F0}</Data> 
  <Data>Failed to backup 1 out of 2 repositories.</Data> 
  <Data>00:00:00</Data> 
  <Data>203</Data> 
  </EventData>
  </Event>

尝试改变

*[System[(EventID=6702)]] and *[EventData[Data[1]='MyBackupJob']]

//Event[EventData[Data[2]="MyBackupJob"]][System[EventID=6702]] 

看看它是否有效。