Help with EventCreate.exe

ssiadmin
ssiadmin used Ask the Experts™
on
 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")
 
'READS IN NAS BACKUP LOG
Set objFile = objFSO.OpenTextFile("C:\SSI\UBS.txt", 1)
Do Until objFile.AtEndOfStream
    strCharacters = strcharacters + objFile.Read(1)
    'Wscript.Echo strCharacters
Loop
strCharacters = Replace(strcharacters, """", "")
 
intHighNumber = 1000
intLowNumber = 1
 
    Randomize
    intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)
  
'WRITES BACKUP LOG
strCommand = "eventcreate.exe /T INFORMATION /ID """& intnumber &""" /L APPLICATION /SO ""Unified Backup Script"" /D """ & strCharacters & """"
WshShell.exec strcommand

Open in new window

Comment
Watch Question

Do more with

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

Author

Commented:
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: http://www.devguru.com/technologies/wsh/QuickRef/wshshell_LogEvent.html

writelog 0, "Test message"
 
Sub writelog (iType,sText)
 
	Dim oShell
	Set oShell = CreateObject("wscript.shell")
	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.
thanks.

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