tag:blogger.com,1999:blog-6454686814995217416.post138673369442204691..comments2023-02-28T05:43:34.736-08:00Comments on Batcheero: Never Set ErrorlevelArif Sukocohttp://www.blogger.com/profile/02253016747219807790noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-6454686814995217416.post-9930142702594347622015-08-13T05:43:23.682-07:002015-08-13T05:43:23.682-07:00Because of reverse order of revealing ERRORLEVEL, ...Because of reverse order of revealing ERRORLEVEL, ERRORLEVEL 0 is always true, even in case of ERRORLEVEL 1 or higher. So "IF NOT ERRORLEVEL 0" is NEVER true. For what I can understand.gilbihttps://www.blogger.com/profile/08222347150040350499noreply@blogger.comtag:blogger.com,1999:blog-6454686814995217416.post-35506298889848452132009-08-20T07:19:36.293-07:002009-08-20T07:19:36.293-07:00I got burned many times for checking errer levels ...I got burned many times for checking errer levels by using == in an if statement eg. <br /><br />1. if %errorlevel%==0<br />2. if errorlevel==0<br /><br />I've since found that the best method that always works for me is to capture the errorlevel with a statement like:<br /><br />IF NOT ERRORLEVEL 0 set MyErr=%ERRORLEVEL%<br /><br />and then to continue processing with the MyErr variable!Unknownhttps://www.blogger.com/profile/10864422280115717223noreply@blogger.comtag:blogger.com,1999:blog-6454686814995217416.post-7499544131435447932009-04-28T09:43:00.000-07:002009-04-28T09:43:00.000-07:00Machtyn,
Your snippet is missing the % for the err...Machtyn,<br />Your snippet is missing the % for the errorlevel. To use it the way you use it in your snippet, you need to do it like:<br /><br />if %errorlevel% == 0<br />...<br />if %errorlevel% neq 0<br /><br />But assuming you just made a typo in your snippet, the likely cause is that you did not set delayed expansion. Since the command that sets errorlevel to 0 is inside an else() block, you need to use ! to access the real errorlevel value.<br /><br />...<br />) else (<br /> do some code that sets errorlevel to 0<br /> if !errorlevel! neq 0 (<br /> do fail code<br /> )<br />)<br /><br />Please see mhy other post about <A HREF="http://batcheero.blogspot.com/2007/06/how-to-enabledelayedexpansion.html" REL="nofollow">delayed expansion</A> for some more info.Arif Sukocohttps://www.blogger.com/profile/02253016747219807790noreply@blogger.comtag:blogger.com,1999:blog-6454686814995217416.post-68941476509191534462009-04-24T06:41:00.000-07:002009-04-24T06:41:00.000-07:00I know this is an old post, but I found it from an...I know this is an old post, but I found it from another site talking about the errorlevel.<br /><br />I discovered that the following bit of code won't work like you really want it to:<br /><br />some code that fails and sets errorlevel to 1<br />if errorlevel == 0 (<br /> do success code<br />) else (<br /> do some other code that would normally set errorlevel to 0<br /> if errorlevel neq 0 (<br /> do fail code<br /> )<br />)<br /><br />What happens in the second if statement, the errorlevel is always 1.Machtynhttps://www.blogger.com/profile/12970086356341341480noreply@blogger.comtag:blogger.com,1999:blog-6454686814995217416.post-11430550870582282632008-10-29T15:19:00.000-07:002008-10-29T15:19:00.000-07:00Thanks for spreading the word about setting errorl...Thanks for spreading the word about setting errorlevels. That was a source of some of my difficulties.Anonymousnoreply@blogger.com