Multiple Choice Batch Script

how do you allow the user to enter multiple numbers in batch scripting, if prompted?

if he asks the user for 5 options. And the user wanted to choose 1,2,3 , but does not want 4,5 , how to do this in batch scripting?

Did I refer to Select permission for users using a batch file and Multiple selection menus in a batch file?

There are related questions in stackoverflow, but there is no answer, because the answer is incorrect.

Any help would be greatly appreciated.

+1
source share
2 answers

: script JAVA GUI?

, family.txt, , .

@echo off
echo.
echo Selection time!
echo.
echo 1. My father is Joe
echo 2. My mother is Audrey
echo 3. My brother is Jerry
echo 4. My elder sister is June
echo 5. My youngest sister is Awy
echo 6. Include All
echo.

:getOptions
set "choices="
set /p "choices=Type your choices without spacing (e.g. 1,2,3): "

if not defined choices ( 
    echo Please enter a valid option
    goto getOptions
    )

for %%a in (%choices%) do if %%a EQU 6 set choices=1,2,3,4,5
for %%i in (%choices%) do call :option-%%i

echo.
echo Done
pause
exit

:option-1
>> Family.txt echo My father is Joe
exit /B

:option-2
>> Family.txt echo My mother is Audrey
exit /B

:option-3
>> Family.txt echo My brother is Jerry
exit /B

:option-4
>> Family.txt echo My elder sister is June
exit /B

:option-5
>> Family.txt echo My youngest sister is Awy
exit /B
+1

:

@echo off

set /p "$choix=Enter you(s) Choice (1,2,...): "
for  %%a in (%$choix%) do call:choix%%a
exit/b


:choix1
echo Choice 1
exit/b

:choix2
echo Choice 2
exit/b

:choix3
echo Choice 3
exit/b
+1

All Articles