0
完成我有一些蝙蝠文件等待的過程中批處理文件
@echo off
call git clone ssh://[email protected]/~/repo/site C:\git\project
:end
我怎樣才能獲得成功克隆項目的回調,並開始下一個終端程序?
或者我需要使用另一個東西,可能是PowerShell?
完成我有一些蝙蝠文件等待的過程中批處理文件
@echo off
call git clone ssh://[email protected]/~/repo/site C:\git\project
:end
我怎樣才能獲得成功克隆項目的回調,並開始下一個終端程序?
或者我需要使用另一個東西,可能是PowerShell?
您可以使用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
在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"
}