Archive for January 17th, 2006

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


Calendar

January 2006
M T W T F S S
« Sep   May »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Posts by Month

Posts by Category