![Board logo](images/default/logo.gif)
标题: [系统相关] [已解决]批处理菜单10秒内作出选择,否则自动退出该怎么设计 [打印本页]
作者: thp2008 时间: 2022-10-18 21:13 标题: [已解决]批处理菜单10秒内作出选择,否则自动退出该怎么设计
本帖最后由 thp2008 于 2022-10-22 11:25 编辑
我想在批处理中间,加个菜单,让用户10秒内作出选择,如果不选择,则等待10秒后自动退出。10秒内选择,则跳转。- echo.
- echo 请选择你想切换的宽带链路,10秒钟,未选择,将自动退出。
- echo.
- echo A、更改上网链路为- (中国电信)
- echo.
- echo B、更改上网链路为- (中国移动)
- echo.
- echo C、更改上网链路为- (中国联通)
- echo.
- echo D、更改上网链路为- (天威宽带)
- echo.
- echo.
- set choice=
- choice /c abcd /M 请输入选择的字母,不区分大小写,不需要回车:
- IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1%
- if errorlevel 4 goto TianWei
- if errorlevel 3 goto LianTong
- if errorlevel 2 goto YiDong
- if errorlevel 1 goto DianXing
-
- :TianWei
- :LianTong
- :YiDong
- :DianXing
-
- :end
- exit
复制代码
不知道该如何改动,组合。复制代码
感谢!
作者: lancer 时间: 2022-10-19 09:04
choice是可以设置默认选项的,在指定时间以后,默认选择,你看看choice的帮助文件
作者: holley 时间: 2022-10-19 11:23
本帖最后由 holley 于 2022-10-19 11:28 编辑
回复 1# thp2008
这种?- @echo off
- echo.
- echo 请选择你想切换的宽带链路,10秒钟,未选择,将自动退出。
- echo.
- echo A、更改上网链路为- (中国电信)
- echo.
- echo B、更改上网链路为- (中国移动)
- echo.
- echo C、更改上网链路为- (中国联通)
- echo.
- echo D、更改上网链路为- (天威宽带)
- echo.
- echo E、退出
- echo.
- echo.
- set choice=
- choice /C "ABCDE" /D "E" /T 10 /M 请输入选择的字母,不区分大小写,不需要回车:
- IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1%
- if errorlevel 5 goto end
- if errorlevel 4 goto TianWei
- if errorlevel 3 goto LianTong
- if errorlevel 2 goto YiDong
- if errorlevel 1 goto DianXing
-
- :TianWei
- :LianTong
- :YiDong
- :DianXing
- pause
- :end
- exit
复制代码
作者: Echo11 时间: 2022-10-19 11:46
回复 3# holley
可以的,我都是用的 /D /T 扩展来弄的菜单。
作者: thp2008 时间: 2022-10-22 11:24
出差了几天,不方便上网,现在才来回复。谢谢你们,测试没问题,原来自带参数。如此简单。
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |