I seem to always forget how to set an error leve in side a batch file, but [WayBack] Errorlevel – Windows CMD – SS64.com tells how:
- When ending a [WayBack] subroutine, you can use
EXIT /b Nto set a specificERRORLEVEL N. - You can make a [WayBack] batch file return a non-zero exit code by using the [WayBack] EXIT command.
Exit 0
Exit /B 5To force an
ERRORLEVELof 1 to be set without exiting, run a small but invalid command like [WayBack]COLOR 00There is a key difference between the way .CMD and .BAT batch files set errorlevels:
An old .BAT batch script running the ‘new’ internal commands:
APPEND,ASSOC,PATH,PROMPT,FTYPEandSETwill only setERRORLEVELif an error occurs. So if you have two commands in the batch script and the first fails, theERRORLEVELwill remain set even after the second command succeeds.This can make debugging a problem
BATscript more difficult, aCMDbatch script is more consistent and will setERRORLEVELafter every command that you run [[archive.is]source].
It looks like I already used a bare EXIT /B without explaining it in Source: stop/start IIS.
Further reading, including the difference between subroutines, blocks and batch files:
- [WayBack] Set errorlevel in Windows batch file – Stack Overflow
- [WayBack] Batch Files – Error Handling – Stack Overflow
Finally saving Google Groups messages in the way back machine:
- Convert the URL
- Save the latter in archive.is
–jeroen





