If you have a script script.bat containing:
@echo off
echo Hello from script.
exit /b 5
In the command prompt or from another script call
test.bat
echo %errorlevel%
It should show:
C:\Temp>script.bat
Hello from script.
C:\Temp>echo %errorlevel%
5