how do I echo "%errorlevel%"

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jaheaga
Posts: 5
Joined: 04 Oct 2011 14:01

how do I echo "%errorlevel%"

#1 Post by jaheaga » 06 Oct 2011 09:02

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

colargol
Posts: 49
Joined: 28 Sep 2011 13:23
Location: france

Re: how do I echo "%errorlevel%"

#2 Post by colargol » 06 Oct 2011 10:12

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%

jaheaga
Posts: 5
Joined: 04 Oct 2011 14:01

Re: how do I echo "%errorlevel%"

#3 Post by jaheaga » 06 Oct 2011 10:55

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

colargol
Posts: 49
Joined: 28 Sep 2011 13:23
Location: france

Re: how do I echo "%errorlevel%"

#4 Post by colargol » 06 Oct 2011 11:44

:oops: sorry
you just have to escape %

%%errorlevel%%

jaheaga
Posts: 5
Joined: 04 Oct 2011 14:01

Re: how do I echo "%errorlevel%"

#5 Post by jaheaga » 06 Oct 2011 11:53

thank you, I could kiss you right now....... :D :D

Post Reply