這個問題在這里已經有了答案: 變數的行為不符合預期 1 個回答 2天前關閉。
我撰寫了一個批處理腳本,其中查詢在最后的IF陳述句中出現,它將用戶回傳到選單,終止腳本,或者如果輸入無效,則清除控制臺輸出并再次提示用戶。同樣的情況也發生在 else 陳述句的末尾。
如果用戶現在做出選擇,他總是必須做兩次。第一次簡單地再次詢問查詢。
有人對此有解決方案嗎?
部分選單:
:restart
cls
set /p input=enter your prefered number and press "enter":
if "%input%"=="1" ( goto :installsd
) else if "%input%"=="4" ( goto :restoreup
) else if "%input%"=="6" ( goto :end
) else ( goto :restart )
這可以正常作業:
:installsd
...some code...
:A
cls
echo [1] back to menu
echo [2] exit
set /p input=enter your prefered number and press "enter":
if "%input%"=="1" ( goto :restart
) else if "%input%"=="2" ( goto :exit
) else ( goto :A )
但在這里我需要雙重輸入才能回傳選單或退出。
在第一次輸入后它運行goto :B/goto :C然后我回到選單。
:restoreup
if exist "%FilePath
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/428968.html
