I wrote a batch script in which a query comes in an IF statement at the end, which sends the user back to the menu, terminates the script, or if the input is invalid, clears the console output and prompts the user again. The same happens at the end of the else statement.
If the user makes a choice now, he always has to do it twice. The first time the query is simply asked once again.
Does anyone have a solution for this?
Some parts of the menu:
: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 )
This works correctly:
: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 )
But here I need double input to come back to menu or exit.
After the first input it runs goto :B
/goto :C
and THEN I go back to menu.
:restoreup
if exist "%FilePath%backup\patch" (
...some code...
:B
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 :B )
) else (
...some code...
:C
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 :C )
)