Search code examples
windowsbatch-filecmderrorlevel

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?


Solution

  • I found that "exit 0" looks like a good way to deal with this problem.

    Usage Example:

    NET STOP UnderDevService /Y

    exit 0

    if the UnderDevService service is not started.