Stop script package from executing when an error occurs

So, I create several clients using the same script batch. If an error occurs while building the error, this process simply stops and continues with the next one. Since there is a lot of output on the screen, and I do other things, most of the time I miss the build error.

Is there a way to stop the following tasks if there is an error and show a pop-up message to get my attention? Or at least stop execution, so when I return to the command window, I see that a failure has occurred?

@echo off

if "%1"=="?" GOTO HELP

if NOT "%1"=="" set rev=%1
if NOT "%2"=="" set version=%2

@echo on
rem build one 
call perl buildClient.pl -brandName="myBrand" -group="group1" 

rem build two 
call perl buildClient.pl -brandName="myBrand" -group="group2" 

rem build three
call perl buildClient.pl -brandName="myBrand" -group="group3" 

rem build four 
call perl buildClient.pl -brandName="myBrand" -group="group4" 


    @echo off

    goto EXIT

    :HELP
    cls
    echo.
    echo.
    echo usage: buildbrand.bat [revision] [version] [group]
    echo.
    echo        ?           = this help screen
    echo.
    echo        revision    = build version
    echo                      Example: 5.2.31
    echo        group       = group of phones or phone name
    echo                      Example: SonyEricsson\K750
    echo.
    :EXIT
    set version=
    set rev=
    set brandName=
    PAUSE
+5
source share
3 answers

" if, /b ( , cmd.exe) 1 ."

if %errorlevel% neq 0 exit /b %errorlevel%

: ?

+4

, :

ERRORLEVEL 1

0

Just try using

if %ERRORLEVEL% NOT 1 
exit 0

in your code. this should come out with an error.

-3
source

All Articles