What is the easiest way to reset ERRORLEVEL to zero? What is the easiest way to reset ERRORLEVEL to zero? windows windows

What is the easiest way to reset ERRORLEVEL to zero?


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


Seems to do the trick:

ver > nul

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

echo. > nulcls > nul


In a pre- or post-build event, if the return code of an executable is greater than zero, and the call to the executable is not the last line of the pre- or post-build event, a quick way mute it and avoid triggering a check for a non-zero errorlevel is to follow the failing line with a line that explicitly returns zero:

cmd /c "exit /b 0"

This is essentially a generic combination of the previously-mentioned solutions that will work with more than just the last line of a pre- or post-build event.