bat定时任务

本文由 @lonelyrains 出品,转载请注明出处。 
文章链接: http://blog.csdn.net/lonelyrains/article/details/45149791


1、功能:windows平台定时完成某任务

2、要点:

1)定时实现: ping

2)时间比较:"11:00:00" == "%time:~0,8%"

3)不断循环:goto

4)具体功能:可能是启动某个程序、打印某个日志


bat脚本代码:

@echo off
:Again
if "11:00:00" ==  "%time:~0,8%" (
    echo "Called000000000000000", 
    ping 127.0.0.1 -n 2
    goto Again
) else ( 
    if "16:00:00" ==  "%time:~0,8%" (
    echo "Called11111111111111", 
    ping 127.0.0.1 -n 2
    goto Again
    ) else ( 
        if "13:55:00" ==  "%time:~0,8%" (
            echo "Called22222222222222", 
            ping 127.0.0.1 -n 2
            goto Again
        ) else (
            echo "Waiting Call",
            echo %time:~0,8%,
            ping 127.0.0.1 -n 2
            goto Again
        )
    )
)

你可能感兴趣的:(windows,脚本)