title: wevtutil in batch file
body: <p>This is part of my batch file. I need to query from Windows event log for system events 33 and 34, this is all about the NIC speed if it is running in 100 full or 100 half duplex. Got the query from event log XML. If I run the command to query for all the events (Anytime) I am getting so many results, all I need is the latest one which is on the last line of the result. </p>
  
  <p>Query for Last 7 days was a better option because it only gives me 1 result (confirmed from GUI) and it will be faster if I need to run a query to many remote PC. However running from command I am getting "A syntax error occurred at position 2. Failed to open event query. The specified query is invalid."</p>
  
  <p>I wonder if the query that was generated from eventvwr have issue or it I need to escape some special characters in this query?</p>
  
  <p>My second option is to just use the query for Anytime and write that last line to a file. This part I don't know how to create in batch. </p>
  
  <p>Anytime:</p>
  
  <pre><code>wevtutil /r:%1 qe System "/q:*[System[Provider[@Name='e1kexpress'] and (Level=4 or Level=0) and (EventID=33 or EventID=34)]]"
  </code></pre>
  
  <p>Last 7 days</p>
  
  <pre><code>wevtutil /r:%1 qe System "/q:*System[Provider[@Name='e1kexpress'] and (Level=4 or Level=0) and (EventID=33 or EventID=34) and TimeCreated[timediff(@SystemTime) &amp;lt;= 604800000]]]"
  </code></pre>