windows事件日志写入sqlserver
欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入 Set objConn = CreateObject("ADODB.Connection") Set objRS = CreateObject("ADODB.Recordset") objConn.Open "Provider=SQLOLEDB.1;Password=****;Persist Security Info=True;User ID=zhang;Ini
欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入
Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
objConn.Open "Provider=SQLOLEDB.1;Password=****;Persist Security Info=True;User ID=zhang;Initial Catalog=IPOPJ;Data Source=SV3\SQLEXPRESS"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM EventTable" , objConn, 3, 3
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = Date - 1
dtmEndDate.SetVarDate Date, True
dtmStartDate.SetVarDate DateToCheck, True
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Security' "_
& " And TimeWritten >= '" & dtmStartDate & "' and TimeWritten
For each objEvent in colEvents
objRS.AddNew
objRS("Category") = objEvent.Category
objRS("ComputerName") = objEvent.ComputerName
objRS("EventCode") = objEvent.EventCode
objRS("Message") = objEvent.Message
objRS("RecordNumber") = objEvent.RecordNumber
objRS("SourceName") = objEvent.SourceName
objRS("TimeWritten") = objEvent.TimeWritten
objRS("Type") = objEvent.Type
objRS("UserName") = objEvent.User
objRS.Update
Next
objRS.Close
objConn.Close
下一篇: 快速查找对方IP地址经典技巧汇总
推荐阅读
-
Powershell使用WINDOWS事件日志记录程序日志
-
c#.NET中日志信息写入Windows日志中解决方案
-
C#3.0使用EventLog类写Windows事件日志的方法
-
使用批处理for命令清除事件查看器所有Windows EventLog日志
-
使用批处理清除事件查看器所有Windows EventLog日志的代码
-
windows事件日志写入sqlserver
-
windows7 sqlserver2012 无法写入受保护的内存 解决办法
-
c#.NET中日志信息写入Windows日志中解决方案
-
Powershell使用WINDOWS事件日志记录程序日志
-
使用批处理for命令清除事件查看器所有Windows EventLog日志