VBSCript write to Windows Event Log

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

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

This entry was posted in Scripting and tagged , , , . Bookmark the permalink.