2016-11-22 39 views

回答

2

您可以使用ERRORLEVEL看是否最後一個命令失敗或不

這樣

if %ERRORLEVEL% == 0 GOTO continue 
if %ERRORLEVEL% == 1 GOTO error 

:continue 
    echo do what you want here after successfully cloned 
    goto exit 

:error 
    echo do your error handling here 

:exit 
1

在poweshell你可以可以調用命令,然後檢查$lastexitcode變量,如果命令完成它會如果它失敗,則爲0,它將爲1。使用簡單的if你可以處理如下:

call git clone ssh://[email protected]/~/repo/site C:\git\project 

if ($lastexitcode) { 
    Write-Host "Failed" 
    #error handling code here 
} 
else { 
    Write-Host "Completed" 
}