批处理脚本多选

如果提示您如何允许用户在批量脚本中键入多个数字?

如果它提示5个选项给用户。 而用户想select1,2,3而不想4,5 ,如何在批处理脚本中做到这一点?

我提到允许使用batch file和batch file上的 多个选项菜单的 用户的 多项selectselect?

在计算器中有相关的问题,但没有答案,因为答案是不正确的。

任何帮助将不胜感激。

这个答案也是指这个问题: 如何将批处理脚本多选到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 (eg 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 

喜欢这个 :

 @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