Raise custom Windows Events using vbscript.

Posted on 2014-08-18
Medium Priority
Last Modified: 2015-02-22
I am looking for a way I can raise Windows Events using vbscript. I want to raise an event...

Type: Information
Date: ...
Time: ...
Source: {Want to be able to dynamically assign this}
Category: None
Event: {Want to use my own event ID here e.g. 2342}
User: N/A
Computer: {Whatever it happens to be}

I have found this code online:

Set shell = CreateObject("WScript.Shell")
shell.LogEvent 4, "Your Message Here"

But this does not provide the level of customisation I want as above...

Any ideas?
Question by:Blowfelt82
1 Comment
LVL 65

Accepted Solution

RobSampson earned 2000 total points
ID: 40269203
Hi, the syntax of the Raise event is
shell.Raise(lngNumber, strSource, strDescription)

so you can set the number, source, and description.  The other thing you can do is use the command line EventCreate utility.

strSource = "MyApp Source"
strID = "201"
strLog = "Application"
strDescription = "This application has started"
strCommand = "cmd /c eventcreate /so """ & strSource & """ /T """ & strType & """ /ID " & strID & " /L """ & strLog & """ /D """ & strDescription & """"
Set objShell = CreateObject("WScript.Shell")
objShell.Run strCommand, 0, True

Open in new window



Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month15 days, 18 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question