Consider the following bat, test.bat (PC01 is off):
mkdir \\\\PC01\\\\c$\\Test || goto :eof
If I run that bat from a command shell:
To build a solution for batch files to set the return code while using goto :eof
you can change your script a bit.
mkdir \\\failure || goto :EXIT
echo Only on Success
exit /b
:exit
(call)
Now you can use
test.bat || echo Failed
The only drawback here is the loss of the errorlevel.
In this case the return code is set to false
but the errorlevel is always set to 1
, by the invalid (call)
Currently I can't found any possible way to set both, the errorlevel and the return code to user defined values