Click here to Skip to main content
15,889,810 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,
I wrote a small batch file:

@echo off

rem runs the {arg[0].exe} - using its fully qualified name
%~f1

IF %errorlevel% NEQ 0 
(set boolResult=False) 
ELSE 
(set boolResult=True) 


rem case1 
EVENTCREATE /T ERROR /ID 700 /L "MyTest Application" /D "exitcode: %errorlevel%; session id is %SessionName%"

rem case3
EVENTCREATE /T ERROR /ID 700 /L APPLICATION /D "exitcode: %boolResult%; session id is %SessionName%"

rem case4 
EVENTCREATE /T ERROR /ID 700 /L APPLICATION /D "exitcode: %errorlevel%; session id is %SessionName%"


And I have got some questions, if you could help me out...

1. case1: I get the following error:
ERROR: 'MyTest Application' log does not exist. Cannot create the event.
The only way to initial eventlog in through high-level (c#) code?

2. case3: How can I concatenate a string with some bat variable ?

3. case4: How do I add a newline in the description?
"exitcode: %boolResult%\n session id is %SessionName%"
didn't do that.

Thanks for any assistance
Posted
Updated 27-May-10 2:09am
v2

1 solution

I haven't used batch files for awhile, but here's how it used to work.

1) If eventlog just needs to be a blank file, then you can create one by using ECHO redirected to a file name. If it needs to be some special format, then you'll need to either copy an existing file or use anotehr method.

2) Usually you just put %1 for commandline parameters and %varname% for environment variables and the batch processor replaces %1 and %varname% with the corresponding parameter string.

3) Not sure how to do that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900