求助,cmd批处理文件如何制定时间运行指定代码?

如8:00~18:00运行live -t 100 -p sock.txt --cid 12312318:01~次日7:59运行live -t 200 -p sock.txt --cid 123123,请问如何实现,高分悬赏,谢谢
2026年09月26日 15:56
有1个网友回答
网友(1):

@echo off & title 根据时间段运行 By 依梦琴瑶
setlocal enabledelayedexpansion

call :GetNowTime

:RunPart1
::8:00~18:00
live -t 100 -p sock.txt --cid 123123

::如果需要循环运行,请把下面的exit指令删除或用注释符进行屏蔽
exit
call :GetNowTime


:RunPart2
::18:01~7:59
live -t 200 -p sock.txt --cid 123123

::如果需要循环运行,请把下面的exit指令删除或用注释符进行屏蔽
exit
call :GetNowTime


:GetNowTime
set NowTime=%time:~,8%
set NowTime=%NowTime: =0%
set NowTime=%NowTime::=%
if %NowTime% geq 080000 (
    if %NowTime% leq 180000 (
        goto RunPart1
    ) else (
        goto RunPart2
    )
) else (
    goto RunPart2
)
goto :eof