中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-18 00:35
47,814 topics / 349,907 posts / today 4 new / 48,259 members
DOS疑难解答 & 问题讨论 (解答室) » How to use a command in DOS to wait X seconds, then run the default?
Printable Version  958 / 0
Floor1 secowu Posted 2006-03-06 15:56
初级用户 Posts 92 Credits 201
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
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023