Example: exit
Explanation: You will get a "return code 1". Setting the ERRORLEVEL has no effect.
Example: exit /b 0
Explanation: exits the batch file, closes the cmd.exe, and sets the return code to zero.
Example: exit /b -2
Explanation: exits the batch file, closes the cmd.exe, and sets the return code to zero
I write my batch files with GOTO statements that control the exit and return code. This is an example of a batch file that reads a log file line-by-line and examines it for the success/failure string. For example:
@echo off
for /F "delims=" %%a in ("result.log") do (
if "%%a" EQU "success" goto SUCCESS
if "%%a" EQU "failure" goto FAILURE
)
:FAILURE
exit /b -2
:SUCCESS
exit /b 0
0 comments:
Post a Comment