VB Script / Windows Script function used to log to the application event log
Here is a very useful set of functions if you want to log to the application event log in Windows. I’ve used it on scheduled scripts, jobs, HTA (HTML Application).
You can call the LogEvent function with a string that you want to place in the application event log. This defaults as an information event. You can optionally call the LogEvent_ex, LogEventAudit, or LogEventAuditFail functions to specify a different event type. Enjoy!
Sub LogEvent (sNote)
LogEvent_Ex 4, sNote
end sub
Sub LogEventAudit (sNote)
LogEvent_Ex 8, sNote
End Sub
Sub LogEventAuditFail (sNote)
LogEvent_Ex 16, sNote
End Sub
Sub LogEvent_Ex(i, sNote)
‘*Constants:
‘ 1=Error
‘ 2=Warning
‘ 4=Information
‘ 8=Audit Success
‘ 16=Audit Failure
dim ws
set ws = CreateObject(”WScript.Shell”)
ws.LogEvent i, sNote
set ws = Nothing
End Sub
Add comment January 17th, 2006