0
1
I have been looking for a query to act as a trigger in the Task Scheduler. I want to restart my VPN if it RASClient ends (EventID 20226) for any reason except code 631 (The port was closed by the user)
I have found a query that Presser provided
<QueryList>
<Query Id="0" Path="Application">
<Select Path="Application">*[System[Provider[@Name='RasClient'] and (EventID=20226)]] and *[EventData[Data[4]='829' or '629']]</Select>
</Query>
</QueryList>
and while it finds terminations (20226) it only finds those caused by code 829 or 629. However, there are dozens or possible error codes, and adding each one linked with "or" makes this model unwieldy.
I tried a not equal command ( != ) but could not get it to work. I even found a post where a Owen recommended streamlining the above query by using
<QueryList>
<Query Id="0" Path="Application">
<Select Path="Application">*[System[Provider[@Name='RasClient'] and (EventID=20226 or EventID=20227)]] and *[EventData[Data[4]!='631']]</Select>
</Query>
</QueryList>
However, this query returns NO results, so I believe there must be a logic flaw in there somewhere.
The second query is closer to what I am looking for as it includes EventID 20226 and 20227 but I would still like to exclude code 631 from the query.
For now what I am using is
<QueryList>
<Query Id="0" Path="Application">
<Select Path="Application">*[System[Provider[@Name='RasClient'] and (EventID=20226 or EventID=20227)]]</Select>
</Query>
</QueryList>
Of course this still restarts my VPN even if I disconnect, but it is a temporary work-around, until I find a better query. For now, if I manually disconnect, I use Ctrl-C to break the script from reconnecting.
Does anyone have any suggestions on how to write this query to include any EventID20226 that has any error code other than 631?