不知道是否bug,我在同一个bat里面,
用到2次choice选择,
但第2次的errorlevel获取的值始终有问题。
Win10 Pro 1507。
例如:- @echo off
- :Start
- echo.
- choice /c 1234569 /M 请输入数字:
- echo.
- if errorlevel 9 set Number1=9 & goto Next
- if errorlevel 8 set Number1=8 & goto Next
- if errorlevel 7 set Number1=7 & goto Next
- if errorlevel 6 set Number1=6 & goto Next
- if errorlevel 5 set Number1=5 & goto Next
- if errorlevel 4 set Number1=4 & goto Next
- if errorlevel 3 set Number1=3 & goto Next
- if errorlevel 2 set Number1=2 & goto Next
- if errorlevel 1 set Number1=1 & goto Next
-
- :Next
- choice /c 1234569 /M 请输入数字2:
- if errorlevel 9 set Number2=99 & goto Next2
- if errorlevel 8 set Number2=88 & goto Next2
- if errorlevel 7 set Number2=77 & goto Next2
- if errorlevel 6 set Number2=66 & goto Next2
- if errorlevel 5 set Number2=55 & goto Next2
- if errorlevel 4 set Number2=44 & goto Next2
- if errorlevel 3 set Number2=33 & goto Next2
- if errorlevel 2 set Number2=22 & goto Next2
- if errorlevel 1 set Number2=11 & goto Next2
-
- :Next2
-
- echo Number1是:%Number1%
- echo.
- echo Number2是:%Number2%
- echo =========================
- goto Start
复制代码 请看我截图的测试。第2次的choice输入9后,本来应该显示99的,但却显示77 |