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
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:profoxtech-bounces@leafe.com] On Behalf Of Paul Newton Sent: Friday, June 28, 2019 7:49 AM To: profoxtech@leafe.com 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]
Many thanks Tracy
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Tracy Pearson Sent: 28 June 2019 15:34 To: profoxtech@leafe.com 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:profoxtech-bounces@leafe.com] On Behalf Of Paul Newton Sent: Friday, June 28, 2019 7:49 AM To: profoxtech@leafe.com 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]