Error handling using ERRORLEVEL in Windows Batch Script -
we have error handling setup in our scripts shown:
set ret = %errorlevel% if %errorlevel% == 0 goto ppcok if not %ret% == 0 goto error1
someone else wrote above, have few concerns working properly.
i have read if check errorlevel = 0 checking if errorlevel 0 or higher. assumption go ppcok label?
also, examples on web use "if errorlevel 1" or show "if %errorlevel% equ 1" , above uses "if %errorlevel% == 0" wondering if there valid case choosing of these 3 methods should used?
on side note not sure why stored errorlevel in variable , used on second if statement rather doing if not %errorlevel% ...
batch sensitive spaces in set
statement. set flag = n
sets variable named "flagspace" value of "spacen"
if errorlevel n
true if errorlevel
n or greater n. if errorlevel 0
therefore true. if not errorlevel 1
test errorlevel=0. if %errorlevel%==0
, exept former can used within block latter cannot.
Comments
Post a Comment