@echo off
set /p Shutdown5=Would you like to shutdown your computer in 5 seconds?
If "%INPUT%" == "y" goto yes
If "%INPUT%" == "n" goto no
:yes
echo Shutting down in 5
/t 1
echo Shutting down in 4
/t 1
echo Shutting down in 3
/t 1
echo Shutting down in 2
/t 1
echo Shutting down in 1
/t 1
echo Shutting down.
:no
exit
以上是一个对我不起作用的代码。任何人都可以指出我的错误,我100%不确定......
答案 0 :(得分:0)
此脚本无法运行,因为/t
不是命令。我想你想使用TIMEOUT /T 1
,这意味着超时1秒。所以试试这个:
@echo off
set /p Shutdown5=Would you like to shutdown your computer in 5 seconds?
If "%INPUT%" == "y" goto yes
If "%INPUT%" == "n" goto no
:yes
echo Shutting down in 5
timeout /t 1
echo Shutting down in 4
timeout /t 1
echo Shutting down in 3
timeout /t 1
echo Shutting down in 2
timeout /t 1
echo Shutting down in 1
timeout /t 1
echo Shutting down.
:no
exit
如果您还想避免使用timeout命令回显的消息,请改用:
timeout /t 1 >nul 2>&1