Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the easiest way to reset ERRORLEVEL to zero?

I have a post-build event that runs some commands for a c# project. The last command would sometimes cause the ERRORLEVEL value not equals to zero and then the build fails.

I want to append an extra line of command to always set the ERRORLEVEL value to zero. What is the most convenient way to do that?

like image 743
user95319 Avatar asked Jul 11 '09 13:07

user95319


People also ask

What is Errorlevel in batch file?

Error Level. The environmental variable %ERRORLEVEL% contains the return code of the last executed program or script.

What does exit B mean?

EXIT /B at the end of the batch file will stop execution of a batch file. use EXIT /B < exitcodes > at the end of the batch file to return custom return codes. Environment variable %ERRORLEVEL% contains the latest errorlevel in the batch file, which is the latest error codes from the last command executed.

What does Errorlevel mean?

In Microsoft Windows and MS-DOS, an errorlevel is the integer number returned by a child process when it terminates. Errorlevel is 0 if the process was successful. Errorlevel is 1 or greater if the process encountered an error.


2 Answers

if you use exit /b 0 you can return an errorlevel 0 from within a child batch script without also exiting the parent.

like image 80
akf Avatar answered Sep 29 '22 07:09

akf


Seems to do the trick:

ver > nul 

Not everything works, and it is not clear why. For example, the following do not:

echo. > nul cls > nul 
like image 34
Jason Kresowaty Avatar answered Sep 29 '22 07:09

Jason Kresowaty