VBScript write to custom event log on remote machine

Posted on 2004-08-06
Last Modified: 2010-05-18
I know that it is possible to create a custom event log on a remote machine using:

Const NO_VALUE = Empty
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite "HKLM\System\CurrentControlSet\Services\EventLog\[CUSTOM_EVENT_LOGNAME]\", "\\[REMOTE_COMPUTER]"

and you can write events to a remote Application event log using:

Set objShell = Wscript.CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_ERROR, _
    "My custom message." , "\\[REMOTE_COMPUTER]"

But, how would you write a custom event to a custom event log on a remote machine?

FYI, I have already looked at "How To Write to the Windows NT/Windows 2000 System Log by Using the Windows Script Host" ( ) which does not provide any useful clues.

Need to make sure that this is in VBScript and since I need an answer quickly I will assign maximum points.

Question by:Mirfster
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 22

Expert Comment

ID: 11742947
As far as I know there is no function in WScript/VBScript that you can use to report an event to log other than "Application"... The hard way would be to write the log file manually... However there are some APIs and DLLs that can be used for that


Author Comment

ID: 11751688
Can you inform me of the proper DLLs, with perhaps a sample script?

What I am trying to accomplish here is to log Success/Failures of pushing out MSI packages through GPO.  Active Directory does not provide logging, except on the target machines, as to if the "push" was successful or failed.

Since I create the MSIs, I would like to add custom code to the end of the installation that would simply log the [ProductName], [ComputerName], [Date], [Time] and a [Success/Failure Message] to an custom event log on a "Tracking" machine.

I can call DLLs that either reside on the local machine or embed them in the package.  So any information regarding the DLLs or APIs that leads me to accomplishing my goal would still result in an "Accepted Answer".

LVL 22

Accepted Solution

DarkoLord earned 500 total points
ID: 11751948
Here is a DLL that can be used to call APIs:

Here is a sample code for writing to event log in VB:

Code would be something like this (maybe you need to fix it a little):

Dim UserWrap, LogHandle, retVal
Set UserWrap = CreateObject("DynamicWrapper")
UserWrap.Register "advapi32.dll", "RegisterEventSource", "i=ss", "f=s", "r=l"
UserWrap.Register "advapi32.dll", "ReportEvent", "i=lllllllsp","f=s","r=l"      'i hope that "p" is correct, if it doesnt work, try to change it so s(tring) or l(ong)
LogHandle = UserWrap.RegisterEventSource("servername", "customLogName")
retVal = UserWrap.ReportEvent(1, 1, 3, 0, 1, 0, "message", 0)


Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WPF - External data binding to controls inside a UserControl 2 78
java continue statement 10 163
Problem to open Excel file 15 223
collection output issue 9 64
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to implement Singleton Design Pattern in Java.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

733 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