IT猫扑网:您身边最放心的安全下载站! 最新更新|软件分类|软件专题|手机版|论坛转贴|软件发布

您当前所在位置:首页操作系统windows → windows事件日志写入sqlserver

windows事件日志写入sqlserver

时间:2015/6/28来源:IT猫扑网作者:网管联盟我要评论(0)

  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 < '" & dtmEndDate & "'")

  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

关键词标签:windows,事件日志,sql

相关阅读

文章评论
发表评论

热门文章 windows7虚拟光驱安装和使用方法windows7虚拟光驱安装和使用方法解决应用程序正常初始化(0xc0000135)失败解决应用程序正常初始化(0xc0000135)失败hosts文件位置以及如何修改hosts文件hosts文件位置以及如何修改hosts文件[声音故障]XP没有声音,丢失Windows Audi[声音故障]XP没有声音,丢失Windows Audi

相关下载

人气排行 [声音故障]XP没有声音,丢失Windows Audio服务(AudioSrv)[警解决Windows 7黑屏的有效方法windows2003中关于软路由设置方法的具体介绍Windows不能在本地计算机启动OracleDBConsoleorcl一个空文件夹删不掉的解决办法Windows 7加XP的局域网搭建与文件共享用Windows命令行实现自动SSH代理Windows提示错误应用程序update.exe