0
我的短批處理文件一直失敗。我的if有什麼問題?超級簡單的錯誤,批處理語句
:user
set /p usercommand = "Input: "
if %usercommand% equ "done"
echo got here!
goto end
else
echo not done
goto user
我的短批處理文件一直失敗。我的if有什麼問題?超級簡單的錯誤,批處理語句
:user
set /p usercommand = "Input: "
if %usercommand% equ "done"
echo got here!
goto end
else
echo not done
goto user
第一 - 與set /p usercommand =
您設置名爲usercommand<space>
變量。刪除預定名稱後的空格(因此它變成了set /p usercommand=
)。
也就是說,如果其他語法不正確,您將會將您帶入另一個錯誤中作爲。它必須是:
if "%usercommand%" equ "done" (
your commands here
) else (
your commands here
)
請注意我報價爲%usercommand%
。沒有這一點,你的比較永遠不會是真實的(除非你需要你的輸入被明確引用)