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.

  1. i have read if check errorlevel = 0 checking if errorlevel 0 or higher. assumption go ppcok label?

  2. 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

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -