Solved

Schedule task on an event

Posted on 2014-09-29
3
658 Views
Last Modified: 2014-10-05
I want to run a batch file in task scheduler on an event.

This is the event in windows events viewer in xml eventdata

 <System>
  <Provider Name="User32" Guid="{b0aa8734-56f7-41cc-b2f4-de228e98b946}" EventSourceName="User32" /> 
  <EventID Qualifiers="32768">1074</EventID> 
  <Version>0</Version> 
  <Level>4</Level> 
  <Task>0</Task> 
  <Opcode>0</Opcode> 
  <Keywords>0x8080000000000000</Keywords> 
  <TimeCreated SystemTime="2014-09-25T23:21:17.892345300Z" /> 
  <EventRecordID>10427</EventRecordID> 
  <Correlation /> 
  <Execution ProcessID="568" ThreadID="1816" /> 
  <Channel>System</Channel> 
  <Computer>SV1.nortool.local</Computer> 
  <Security UserID="S-1-5-21-3322805290-1362380017-3951582809-1106" /> 
  </System>
- <EventData>
  <Data Name="param1">C:\Windows\Explorer.EXE (SV1)</Data> 
  <Data Name="param2">SV1</Data> 
  <Data Name="param3">Other (Unplanned)</Data> 
  <Data Name="param4">0x5000000</Data> 
  <Data Name="param5">power off</Data> 
  <Data Name="param6" /> 
  <Data Name="param7">NORTOOL\NTAdmin</Data> 
  </EventData>
  </Event>

Open in new window


I want to run the batch file for this event data:
 <EventID Qualifiers="32768">1074</EventID> 
<Data Name="param5">power off</Data> 

Open in new window


When in the task schedule I created the following in the "Edit Event Filter" screen and need to know how to include <Data Name="param5">power off</Data>

<QueryList>
  <Query Id="0" Path="System">
    <Select Path="System">*[System[(EventID=1079)]]</Select>
  </Query>
</QueryList>

Open in new window


This is for a Windows 2012 R2 server
0
Comment
Question by:Gerhardpet
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 40354171
This should do the trick:
<QueryList>
  <Query Id="0" Path="System">
    <Select Path="System">*[System[(EventID=1074)]][EventData[(Data[@Name='param5']='power off')]]</Select>
  </Query>
</QueryList>

Open in new window

which is equivalent to:
<QueryList>
  <Query Id="0" Path="System">
    <Select Path="System">*[System[(EventID=1074)] and EventData[(Data[@Name='param5']='power off')]]</Select>
  </Query>
</QueryList>

Open in new window

So the first one (which for no particular reason is my personal preference) uses 2 consecutive "[ ... ]" selectors which are both applied to * (which always matches the Event node) where the second one uses "... and ..." to do the same.

Here are some more examples: http://msdn.microsoft.com/en-us/library/aa385231(VS.85).aspx

In general, it should be possible to use any XPath query selector: http://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 40354176
tested in Event Viewer filter:
captureThe events where 'param5' is 'shutdown' or 'restart' are not shown anymore, so seems to work ok ;-)
0
 
LVL 1

Author Closing Comment

by:Gerhardpet
ID: 40362102
That did the trick. Thank you Robert!!
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve DNS query failed errors for Exchange
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now