windows监控进程是否存在
@echo off
:run
tasklist /FI "IMAGENAME eq SDPAgent.exe" 2>NUL | find /I /N "SDPAgent.exe">NUL
if "%ERRORLEVEL%"=="0" (
echo Program is running
for /f "skip=3 tokens=2 " %%i in ('TASKLIST /FI "IMAGENAME eq SDPAgent.exe" /FI "STATUS eq NOT RESPONDING"') do (
echo %Date% %time% %%i
taskkill /F /PID %%i /T @REM 进入这里就是无响应 自己 kill 掉
)
) else (
echo Program is NONONO running
C:\\Users\\23921\\Desktop\\error.mp3
exit
)
choice /t 1 /d y /n > null
goto run