Batch files return the error code of the last command by default.
Is it somehow possible to return the error code of a former command. Most notably, is it possible t
One workaround is to make an indirection through a file.
Like this
foo.exe > tmp.txt set FOOERR=%ERRORLEVEL% cat tmp.txt exit %FOOERR%