The Exit command will set an ExitCode into the ERRORLEVEL.

The syntax is:

exit \[/b\] \[ExitCode\]

where the /b exits the current batch script, as apposed to CMD.exe, the command interpreter, and ExitCode is a numeric value used to set the ERRORLEVEL.