Solved

VBScript write to custom event log on remote machine

Posted on 2004-08-06
6
13,008 Views
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]"
    NO_VALUE

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

Const EVENT_SUCCESS = 0
Const EVENT_ERROR = 1
Const EVENT_WARNING = 2
Const EVENT_INFORMATION = 4
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" ( http://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3B257541 ) 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.

Thanks.
0
Comment
Question by:Mirfster
[X]
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
6 Comments
 
LVL 22

Expert Comment

by:DarkoLord
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

Darko
0
 
LVL 8

Author Comment

by:Mirfster
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".

Thanks.
0
 
LVL 22

Accepted Solution

by:
DarkoLord earned 500 total points
ID: 11751948
Here is a DLL that can be used to call APIs:
http://www.borncity.de/WSHBazaar/WSHDynaCall.htm

Here is a sample code for writing to event log in VB:
http://www.mentalis.org/apilist/3E333A9BA6779769EB5D9723FB7FCAA7.html

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)

Darko
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

717 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