在 Windows 批处理文件 (x.bat) 中,当时间的第二部分大于 55 时,如何每 30 分钟触发一次命令?
我现在拥有的是:
:loop
program.exe
PING localhost -n 1800 >NUL
goto loop
问题是时间不够精确,即。秒 > 55 在 min%30==29。
在 Windows 批处理文件 (x.bat) 中,当时间的第二部分大于 55 时,如何每 30 分钟触发一次命令?
我现在拥有的是:
:loop
program.exe
PING localhost -n 1800 >NUL
goto loop
问题是时间不够精确,即。秒 > 55 在 min%30==29。
如前所述,任务计划程序能够胜任这项任务。它可以每天运行一次,每 30 分钟一次,从next hour:59:55
也就是说,有一些方法可以编写这些内容。这不是最强大的解决方案,但它确实有效。
@echo off
:start
for /f %%i in ('powershell Get-Date -Format mm:ss') do (
if "%%i"=="29:55" program.exe
if "%%i"=="59:55" program.exe
timeout 1 /nobreak>nul
)
goto start