I would like to prevent user's choices except default options defined in the relevant menus.
ECHO Select a file
ECHO.
ECHO 1. Process File and commands
ECHO 2. Another File and commands
ECHO 3. Yet another file and its commands
ECHO 4. Disconnect
ECHO 5. Exit
ECHO.
set /p choice="Choose an option: "
if "%choice%"=="1" goto smenu_1
if "%choice%"=="2" goto smenu_2
if "%choice%"=="3" goto smenu_3
if "%choice%"=="4" goto smenu_4
if "%choice%"=="5" goto End
:smenu_1
ECHO Select another option
ECHO.
ECHO 1 - This is an option
ECHO 2 - Back to Start
ECHO.
SET /P M=Choose an option:
IF %M%==1 GOTO This_Submenu_Does_Multiple_Commands
IF %M%==2 GOTO start
This is my sample code. In the main menu, if I enter "6", it automatically goes to first sub menu. I tried for many options offered here in similar questions or through the web like input validation or something similar. What I want to have user to enter one of the numbers given in the options. For instance, in main menu if "6" chosen or maybe "25", it should warn the user that a wrong option selected and give a try more. I would like to have this for all sub menus. In addition, yet another question arises at this point: Menu options may be more than 30 options meaning that may not be only single digits. Could you show me how to limit user input as many as menu options (including submenu options may vary to the number of their own options). Thanks in advance.