我需要一种方法来提示用户使用批处理输入 [英] I need a way to prompt a user for an input using batch

查看:41
本文介绍了我需要一种方法来提示用户使用批处理输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到有关如何制作一个批处理的帖子,该批处理根据输入打开另一个批处理.但是,我需要一种方法来使代码暂停,直到输入正确的输入,然后继续.

I noticed a post on how to make a batch that opens another batch upon an input. However, I need a way that will make the code pause until the correct input is entered, then continue.

例如,代码将询问什么是访问代码?

So for example, the code would ask what is the access code?

然后用户将输入正确的代码,例如123.

Then the user would input the correct code, for example 123.

然后代码将显示"Welcome!"(欢迎!)然后它将执行另一个问题,例如您今天想做什么?"将会有一个选项列表:

Then the code would say "Welcome!" Then it would execute another question like "What do you want to do today?" There would be a list of options:

A.游戏

B.浏览

C.没关系

用户将输入a,b或c,脚本将启动游戏或网络浏览器.如果用户选择了C,则它将退出.

The user would in put a, b, or c and the script would start either a game or web browser. If the user selected C, then it would exit.

感谢您的帮助!

推荐答案

@echo off

echo Welcome!
echo What do you want to do today?
echo.
echo A. Game
echo.
echo B. Browse
echo.
echo C. Nevermind
echo.

choice /C:ABC /N /M "Enter your choice:  "
if "%errorlevel%"=="1" goto :game
if "%errorlevel%"=="2" goto :browse
if "%errorlevel%"=="3" goto :nevermind
goto :error

这篇关于我需要一种方法来提示用户使用批处理输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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