Page 1 of 1

how do I echo "%errorlevel%"

Posted: 06 Oct 2011 09:02
by jaheaga
how do I echo "%errorlevel%" to a file?
example:

echo if '%errorlevel%' == '0' (>>file.bat


I tried with ^ but it doesn't work.

This would help to solve my previous question.


Thank you

Re: how do I echo "%errorlevel%"

Posted: 06 Oct 2011 10:12
by colargol
Hi

Code: Select all

echo %errorlevel% 1>"file.bat"

The 1 before > means you want to write standard output :)

Have a look

or

Code: Select all

>"file.bat" echo %errorlevel%

Re: how do I echo "%errorlevel%"

Posted: 06 Oct 2011 10:55
by jaheaga
thankyou, but what I want is literaly print the %errorlevel% word, not the value
so it can be readed correctly from the batch file I am creating.

the complete line is this:

Code: Select all

 if '%errorlevel%' == '0' (


thats the line I wanna put in the new batch, so I can call it later in the script

the batch I'm trying to print is this

viewtopic.php?f=3&t=2305

Muchas Gracias..... Thankyou

Re: how do I echo "%errorlevel%"

Posted: 06 Oct 2011 11:44
by colargol
:oops: sorry
you just have to escape %

%%errorlevel%%

Re: how do I echo "%errorlevel%"

Posted: 06 Oct 2011 11:53
by jaheaga
thank you, I could kiss you right now....... :D :D