Many thanks Tracy -----Original Message----- From: ProfoxTech <[email protected]> On Behalf Of Tracy Pearson Sent: 28 June 2019 15:34 To: [email protected] Subject: RE: Problem with WMI query
Sent by an external sender ------------------------------ Hi Paul, This site has your answer in the Copy the Previous Day's Events to a Database. https://www.activexperts.com/admin/vbscript-collection/logs/event/ The important parts follow: Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime") Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime") DateToCheck = Date - 1 dtmEndDate.SetVarDate Date, True dtmStartDate.SetVarDate DateToCheck, True Set colEvents = objWMIService.ExecQuery _ ("Select * from Win32_NTLogEvent Where TimeWritten >= '" _ & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'") HTH, Tracy -----Original Message----- From: ProfoxTech [mailto:[email protected]] On Behalf Of Paul Newton Sent: Friday, June 28, 2019 7:49 AM To: [email protected] Subject: Problem with WMI query Hi all I have tried to run a WMI query to process Application events on or after a certain date (SearchEventStart). I have tried each of the following formats for SearchEventStart to no avail. 20190628123502.000000+000 28/06/2019 12:34:10 PM 2019-06-28 12:35:27:000 The code I am using looks like this: strComputer = "." objWMIService = GetObject("winmgmts:\\" + strComputer + "\root\cimv2") colEvents = objWMIService.ExecQuery( "Select * from Win32_NTLogEvent Where Logfile = 'Application' And TimeWritten >= '" + SearchEventStart + "'" ) This does not work but it works if I omit the second part of the WHERE clause like so: colEvents = objWMIService.ExecQuery( "Select * from Win32_NTLogEvent Where Logfile = 'Application'") Any ideas? Any help would be much appreciated. Thanks Paul Newton [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: https://leafe.com/archives This message: https://leafe.com/archives/byMID/mn2pr02mb5967297ce4d9fef1ed05a90ca1...@mn2pr02mb5967.namprd02.prod.outlook.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

