在Windows批处理程序中使用WIMC 查找正在运行的进程

@echo off

:SLEEP
TIMEOUT /T 60 /NOBREAK

:CHECK
echo %TIME% | findstr 23:5 >nul
if not errorlevel = 1 goto END

WMIC PROCESS WHERE NAME="java.exe" get commandline | findstr /i helloworld >nul
if not errorlevel goto RUNNING

:RUN
cd /D W:\external\input\input-trigger
if exist *-* (
    echo %date% - %time% - trigger file exist, start up the run.bat >>d:\temp\log.txt
    call d:\apps\run.bat
    goto SLEEP
) else (
    echo %date% - %time% - trigger file does not exist >>d:\temp\log.txt
    goto SLEEP
)

:RUNNING
echo %date% - %time% - helloworld is running >>d:\temp\log.txt
goto SLEEP

:END

posted @ 2016-04-02 22:29  醇香的思念  阅读(1621)  评论(0编辑  收藏  举报