批处理脚本多重选择 [英] Batch scripting multiple selection

查看:145
本文介绍了批处理脚本多重选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么让用户如果提示多个号码输入到批处理脚本?

how do you allow the user to type multiple numbers into batch scripting if prompted?

如果它提示5个选项给用户。而且用户想选择的 1,2,3 ,但不希望的 4,5 ,该怎么办呢批处理脚本?

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

我来所指向<一个href=\"http://stackoverflow.com/questions/24809638/allowing-multiple-choice-selections-for-users-using-batch-file\">Allowing选择题选择使用批处理文件用户和在批处理文件多选菜单?

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

There is relevant questions in stackoverflow but there is no answer to it because the answer is not right to the point.

任何帮助将大大AP preciated。

Any help would be greatly appreciated.

推荐答案

这答案也提到了这个问题:<一href=\"http://stackoverflow.com/questions/24948004/allowing-users-to-choose-multiple-choices-using-batch-file-and-java\">Allowing用户在使用批处理文件来选择多种选择和Java

This answer also refers to this question: Allowing users to choose multiple choices using batch file and Java

您可能想在顶部加一行删除 family.txt 如果你想要一个新的文件各一次。

You might like to add a line at the top to delete family.txt if you want a new file each time.

@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

这篇关于批处理脚本多重选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆