VB Script / Windows Script function used to log to the application event log
January 17th, 2006
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
Entry Filed under: Programming


Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed