If echo errorlev = %ERRORLEVEL% doesn't throw an error, the exit error of the batch process is 0. There's only 1 error level for a program, and that's the one it sets when it exits. You can save error levels locally (in the batch process) and force an exit level based on a previous error, even though the process has since completed a few further steps with no error.