Help with EventCreate.exe

ssiadmin used Ask the Experts™
 Hi there,

I'm working on a way to get the log file for a robocopy job inserted into the event log. It was going along swimmingly, but I seem to have hit a snag. Using the attached code with the strCharacters variable, it sometimes fails. When I replace the contents of UBS.txt with "123", it works fine. I suspect it's a limit on the /D portion of EventCreate. Anyone run into this before or (better yet) have a better way of doing this?
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFile = objFSO.OpenTextFile("C:\SSI\UBS.txt", 1)
Do Until objFile.AtEndOfStream
    strCharacters = strcharacters + objFile.Read(1)
    'Wscript.Echo strCharacters
strCharacters = Replace(strcharacters, """", "")
intHighNumber = 1000
intLowNumber = 1
    intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)
strCommand = "eventcreate.exe /T INFORMATION /ID """& intnumber &""" /L APPLICATION /SO ""Unified Backup Script"" /D """ & strCharacters & """"
WshShell.exec strcommand

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


The problem seems to lie with old versions of eventcreate.exe. Now just to find a way to replace it...
VBScript has the ability to write to the event logs natively.  It may not be exactly what you want because you can't control every element.  eg it can only write to the Application log and the source is always shown as WSH.
I've pasted a simple Sub below for you to play with but more info here:

writelog 0, "Test message"
Sub writelog (iType,sText)
	Dim oShell
	Set oShell = CreateObject("")
	oShell.LogEvent iType, sText
End Sub

Open in new window

When using EventCreate, where can I locate the ID that is generated?
I have a script using EventCreate that I hardcode the /ID variable, however, once the script runs I cannot locate where the ID is stored, whether its in a log or some other location.
I have answered my own question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial