Concatenate a variable with a string

Posted by user311130 on Stack Overflow See other posts from Stack Overflow or by user311130
Published on 2010-05-27T08:39:41Z Indexed on 2010/05/27 8:51 UTC
Read the original article Hit count: 328

Hello all,

I wrote a small bat 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-leve (c#) code?

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

  2. 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

© Stack Overflow or respective owner

Related posts about batch-file

Related posts about windows-scripting