2016-03-03 79 views
0

我需要知道如果在其他命令窗口中打開的第二個批處理文件已停止(等待參數或進程不成功),我該如何檢查批處理文件。檢查CTRL-C是否按下或批次等待加法

@echo off 
:loop 
start /wait rapidminer-batch.bat -f C:\Users\AHM-PC\Documents\ccc.rmp 
echo cmd stopped 
pause 
goto loop 

enter image description here

回答

0

當稱爲批處理結束時,它返回一個值給errorlevel。它適用於call,也不知道是否爲start

if %errorlevel% gtr 0 (
    echo failed 
) else (
    echo success) 

或致電exit /b <number of error>在你所謂的間歇,返回特定的值。檢查exit瞭解更多詳情。

+0

謝謝!我必須使用「呼叫」功能。 –

0

正常的方法來提供批間通信是flag file

要麼你create主程序的標誌文件,並等待start編程序來刪除它,或者等到start版批處理創建一個文件,刪除它。

echo.>myflag.txt 
start anotherbatch.bat 
:loop 
timeout /t 1 >nul 
if exist myflag.txt goto loop 

在這裏,一批將等到myflag.txt被刪除,你的第二批辦。你所需要的就是讓這兩個例程同意使用一個文件名。