数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

windows事件日志写入sqlserver


发布日期:2022年03月23日
 
windows事件日志写入sqlserver

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

上一篇:Windows7库功能快递管理电脑大硬盘数据

下一篇:通过Vista性能监控器创建数据收集