I have a batch file that runs a richcopy program, I am wanting to monitor the errorlevel so far i have got this
IF (%ERRORLEVEL% == 0) goto OK else IF (%ERRORLEVEL% == 3010) goto Report
:Report
:OK END
What I am wanting to do is to report the error to the event viewer so that it can be monitored via another application that monitors the event logs.
You can use EVENTCREATE
to write to the event log.
An example would be:
EVENTCREATE /T ERROR /L APPLICATION /ID 100 /D "This is your error message."
More information can be found at the TechNet article.
EDIT
In your case, try this. Your parenthesis and use of == may be throwing things off.
@ECHO OFF
IF %ERRORLEVEL% NEQ 3010 goto OK
EVENTCREATE /T ERROR /L APPLICATION /ID 100 /D "This is your error message."
:OK
EXIT
This way, if the error level isn't 3010, it always skips to the OK method, in case you get something other than 0 or 3010.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With