tmpDate = DateAdd("h", -3, Now())
dtmYear = Year(tmpDate)
dtmMonth = Right("0" & Month(tmpDate), 2)
dtmDay = Right("0" & Day(tmpDate), 2)
dtmHour = Right("0" & Hour(tmpDate), 2)
dtmMinute = Right("0" & Minute(tmpDate), 2)
dtmCurDate = dtmYear & dtmMonth & dtmDay & dtmHour & dtmMinute & "00.000000+540"
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colEvents = objWMIService.ExecQuery _
("Select Message, TimeWritten from Win32_NTLogEvent Where TimeWritten >= '" & dtmCurDate & "' AND (EventType =1 OR EventType = 2)")
For each objEvent in colEvents
'Wscript.Echo objEvent.Message
Call smsSend(objEvent.Message)
Next
Function smsSend(msg)
Dim conn
Set conn = CreateObject("ADODB.Connection")
conn.open "Provider=SQLOLEDB.1;Data Source=xxx.xxx.xxx.xxx;Initial Catalog=service","sa","xxxxx"
msg = Now() & " - " & msg
msg = Left(msg, 80)
msg = Replace(msg, "'", "")
'Wscript.Echo msg
conn.execute "INSERT INTO em_tran(tran_id, tran_phone, tran_callback, tran_status, tran_date, tran_msg) VALUES ('xxxxxx', '01000000000', '0200000000', '1', GETDATE(), '" & msg & "')"
Set conn = Nothing
End Function
댓글 없음:
댓글 쓰기