Eventquery.vbs: ERROR: Unable to execute the query for the ‘security’ log

I was querying the Security log from a server with eventquery.vbs, suddenly the Microsoft script returned this error:

ERROR: Unable to execute the query for the 'security' log.

Turned out that this error appears when the Security log is over 10MB, equal to 32767 records. Got it solved by changing CInt by CLng, at Line 1700 – 170

Old code:
If CInt(objLogs.Item(arrKeyName(intLoopCount))) > 0 Then
            strFilterLog = arrKeyName(intLoopCount)
            intRecordRangeFrom = 0
            intRecordRangeTo = CLng(objLogs.Item(arrKeyName(intLoopCount))) 

New code:
If CLng(objLogs.Item(arrKeyName(intLoopCount))) > 0 Then
            strFilterLog = arrKeyName(intLoopCount)
            intRecordRangeFrom = 0
            intRecordRangeTo = CLng(objLogs.Item(arrKeyName(intLoopCount)))

 

4 thoughts on “Eventquery.vbs: ERROR: Unable to execute the query for the ‘security’ log

  1. stupid dummy

    You posted the same code twice silly pants.

  2. bennebiest Post author

    Old code: If CInt
    New code: If CLng

    Added red color to highlight what was changed.

Comments are closed.