China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-30 01:04
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » How to use a command in DOS to wait X seconds, then run the default? View 910 Replies 0
Original Poster Posted 2006-03-06 15:56 ·  中国 广东 东莞 电信
初级用户
★★
Credits 201
Posts 92
Joined 2005-12-28 17:44
20-year member
UID 48072
Status Offline
echo Default is option 1, automatically starts after 5 seconds
echo.
set /P choice= Please enter whether to reboot immediately (1 immediately / 2 later)...
wait 5
IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
IF /I '%Choice%'=='1' GOTO drv
IF /I '%Choice%'=='2' GOTO igr

::If no choice is made, go to the default choice
echo You did not make a choice, this is the default
goto exit
:drv
echo You chose to reboot immediately
exit

:igr
echo You chose to reboot later
exit

:exit
exit

++++++++++++++++++++++++++
I used wait, and it works, but set /p intercepts it
so it can't achieve the expected result

And if I use wait directly, the selection message above disappears
Forum Jump: