Set objConn = CreateObject(ADODBConnection)
Set objRS = CreateObject(ADODBRecordset)
objConnOpen Provider=SQLOLEDB;Password=****;Persist Security Info=True;User ID=zhang;Initial Catalog=IPOPJ;Data Source=SV\SQLEXPRESS
objRSCursorLocation =
objRSOpen SELECT * FROM EventTable objConn
Set dtmStartDate = CreateObject(WbemScriptingSWbemDateTime)
Set dtmEndDate = CreateObject(WbemScriptingSWbemDateTime)
DateToCheck = Date
dtmEndDateSetVarDate Date True
dtmStartDateSetVarDate DateToCheck True
strComputer =
Set objWMIService = GetObject(winmgmts: _
& {impersonationLevel=impersonate}!\\ & strComputer & \root\cimv)
Set colEvents = objWMIServiceExecQuery _
(Select * from Win_NTLogEvent Where Logfile = Security _
& And TimeWritten >= & dtmStartDate & and TimeWritten < & dtmEndDate & )
For each objEvent in colEvents
objRSAddNew
objRS(Category) = objEventCategory
objRS(ComputerName) = objEventComputerName
objRS(EventCode) = objEventEventCode
objRS(Message) = objEventMessage
objRS(RecordNumber) = objEventRecordNumber
objRS(SourceName) = objEventSourceName
objRS(TimeWritten) = objEventTimeWritten
objRS(Type) = objEventType
objRS(UserName) = objEventUser
objRSUpdate
Next
objRSClose
objConnClose