弹跳每60秒 - cmd

时间:2014-02-13 17:20:49

标签: cmd

我希望每隔60秒发送一条消息作为提醒

我试过

@echo off
:loop
msg * Some text
@ping -n 60 -w 1000 0.0.0.1 > NUL
goto loop

@echo off
:loop
msg * Some text
timeout /t 60
goto loop

@echo off
:loop
msg * Some text
ping -n 60 localhost >nul
goto loop

1 个答案:

答案 0 :(得分:0)

这应该有效

@echo off

set /a secs=60
set /a ms=%secs%*1000

:loop
echo Process will wait for %secs% seconds and then continue...
ping 1.1.1.1 -n 1 -w %ms% > nul
msg * done
goto loop

或者制作一个等待x秒的通用脚本,将#sses作为参数调用以下版本,为此你可以在控制脚本中执行msg和循环:

@echo off
rem call with # of seconds to wait

set /a secs=%1
set /a ms=%secs%*1000
echo Process will wait for %secs% seconds and then continue...
ping 1.1.1.1 -n 1 -w %ms% > nul
echo.
::msg * done
exit

稍后添加

@echo off
rem call with # of seconds to wait

:loop
set /a secs=%1
set /a ms=%secs%*1000
echo Process will wait for %secs% seconds and then continue...
ping 1.1.1.1 -n 1 -w %ms% > nul
echo.
msg * done
goto loop
exit