So I wrote this article back in the day about logging to a text file.
And I was asked if there is a way to use windows logging as well.
Short answer yes, long answer yes but it’s not amazing
Very simple code
Set objShell = CREATEOBJECT("WScript.Shell") ' Constants for type of event log entry EL_SUCCESS = 0 EL_ERROR = 1 EL_WARNING = 2 EL_INFO = 4 EL_AUDIT_SUCCESS = 8 EL_AUDIT_FAILURE = 16 WriteToEventLog EL_Warning, "Testing My event log message..." Sub WriteToEventLog(sLogEID,strELMessage) objShell.LogEvent sLogEID, strELMessage End Sub
As you can see above I added some values there are set for the Event ID in the event logs.
Certain Event ID’s will have different Icons and the only problem I see is that the source is WSH and seems can’t be changed.
I’ll Upload some screen shots later on