Solved

Schedule task on an event

Posted on 2014-09-29
3
802 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
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 the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…

688 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