如何将计时器添加到批处理文件?

1 file timer batch-file

我想制作一个等待几分钟的批处理文件,然后执行一个命令.我该怎么做?具体来说,我希望它在打开文件后3分钟内结束另一个程序.

shf*_*301 6

使用timeout.这将让你等待它的/t参数给出的秒数. timeout /t 180将睡3分钟(180秒).

TIMEOUT [/T] timeout [/NOBREAK]

Description:
    This utility accepts a timeout parameter to wait for the specified
    time period (in seconds) or until any key is pressed. It also
    accepts a parameter to ignore the key press.

Parameter List:
    /T        timeout       Specifies the number of seconds to wait.
                            Valid range is -1 to 99999 seconds.

    /NOBREAK                Ignore key presses and wait specified time.

    /?                      Displays this help message.

NOTE: A timeout value of -1 means to wait indefinitely for a key press.

Examples:
    TIMEOUT /?
    TIMEOUT /T 10
    TIMEOUT /T 300 /NOBREAK
    TIMEOUT /T -1
Run Code Online (Sandbox Code Playgroud)


Arr*_*ran 5

另一种方法是在一段时间内 ping 一个无效的 IP 地址:

PING 1.1.1.1 -n 1 -w 60000 >NUL
Run Code Online (Sandbox Code Playgroud)

60000 = 毫秒