2013-03-05 138 views
5

所以我使用相同的批處理腳本構建多個客戶端。如果在構建一個錯誤時出現錯誤,那麼這個過程會停止並繼續下一個過程。由於屏幕上有很多輸出,我正在做其他事情,大多數時候我都會錯過有一個構建錯誤。在遇到錯誤時停止執行批處理腳本

如果出現錯誤,並且顯示彈出消息以引起我的注意,是否有辦法停止執行以下任務?或者至少停止執行,所以當我回到命令窗口時,我可以看到有一個失敗?

@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 
+0

比方說,建設1組失敗。我想停在那裏,讓我自己通知,而不是繼續處理group2。 – Tony 2013-03-05 22:31:27

+1

我不是100%確定的,但我認爲像'call command arguments || echo命令失敗&&暫停'應該工作。 – 2013-03-05 22:35:50

+1

@ProfPickle這是假設perl給出了一個錯誤的級別,我會認爲它沒有。託尼如果失敗會給出什麼輸出? – 2013-03-05 23:01:13

回答

-3

只是一個提示嘗試在代碼中使用

if %ERRORLEVEL% NOT 1 
exit 0 

。這應該在出錯時退出。

0

因爲如果誤差是停止執行正確的語法:只有

如果錯誤級別1退出

相關問題