- @echo off
- set "times=10"
- echo 按任意键退出运行程序,默认 10 秒启动程序
- :bgn
- set/p=还剩下 %times% 秒...<nul
- if "%times%"=="0" goto :run
- set /a "times-=1"
- choice /T 1 /C abcdefghijklmnopqrstuvwxyz /d a >nul
- if "%errorlevel%"=="1" (goto :bgn) else (goto :end)
- :run
- echo.&echo 程序已经启动...
- pause>nul&goto :eof
- :end
- echo.&echo 已经退出程序...
- pause>nul
复制代码
谢谢版主提醒,现更改如下:
- @echo off
- set "times=10"
- echo 按任意字母键退出运行程序,默认 10 秒启动程序
- :bgn
- set/p=还剩下 %times% 秒...<nul
- if "%times%"=="0" goto :run
- set /a "times-=1"
- choice /T 1 /C 0abcdefghijklmnopqrstuvwxyz /d 0 >nul
- if "%errorlevel%"=="1" (goto :bgn) else (goto :end)
- :run
- echo.&echo 程序已经启动...
- pause>nul&goto :eof
- :end
- echo.&echo 已经退出程序...
- pause>nul
复制代码
[ 本帖最后由 more 于 2008-10-22 17:03 编辑 ] |