choice会更改errorlevel值,如果程序中要用到errorlevel值,应该这样写:
- @echo off
- echo 现在errorlevel值为%errorlevel%
- set etmp=%errorlevel%
- choice /c qwertyuiopasdfghjklzxcvbnm1 /n /t 10 /d 1 /m 10s后将运行程序
- if %errorlevel%==27 goto run
- exit
- :run
- cls
- rem 运行程序
- set errorlevel=%etmp%
- echo 程序运行完毕,errorlevel值依然为%errorlevel%
- pause
复制代码
|