批量比较计时器结果到一个数字

时间:2017-09-06 16:20:39

标签: windows batch-file

我有一个批处理计时器(在不同的stackOverFlow帖子中看到它),我需要将经过的时间与数字进行比较,以便知道何时通过10秒,但是,我在尝试比较时遇到错误他们俩。 我做错了什么?

@set /A _tic=%time:~0,2%*3600^
            +%time:~3,1%*10*60^
            +%time:~4,1%*60^
            +%time:~6,1%*10^
            +%time:~7,1% >nul



echo RUN-KILL-WATCHDOG-THE-SMART-WAY

SETLOCAL EnableExtensions
set EXE=python.exe

:RUNNERON
FOR /F "skip=1" %%x IN ('wmic process where "CommandLine Like '%%forking import main%%' and Caption='python.exe'" get caption') DO for /F "delims=" %%j in ("%%x") do (
    echo The name of process who passed filter is: %%j Waiting for it to terminate...
    IF %%j == %EXE% (
        :: TOK
        set /A _toc=%time:~0,2%*3600^
                +%time:~3,1%*10*60^
                +%time:~4,1%*60^
                +%time:~6,1%*10^
                +%time:~7,1% >nul
        set /A _elapsed=%_toc%-%_tic
        :: echo %_elapsed% seconds.
        IF %_elapsed%==10 goto TIMEOUT :: EVERYTHING WORKS BUT THIS LINE
        goto RUNNERON
    ) ELSE (
        echo Entered "else" part - something went wrong.
    )
)
echo Runner is done - killing watchdog process
taskkill /F /im "python.exe"

: TIMEOUT
echo TIMEOUT

pause

当我运行它时,我收到错误: “goto此时出乎意料。”

我错过了什么? 谢谢

0 个答案:

没有答案