Home > Database > Mysql Tutorial > windows事件日志写入sqlserver

windows事件日志写入sqlserver

WBOY
Release: 2016-06-07 15:51:31
Original
1621 people have browsed it

欢迎进入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

windows事件日志写入sqlserver

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template