使用.bat检测崩溃的应用程序

时间:2013-11-28 09:15:55

标签: batch-file

大家好,有可能用.bat代码检测应用程序崩溃,然后用.bat重启。 请求给我一个方法。 我写了一个代码来启动和重新启动应用程序,但我不知道如何检测崩溃的应用程序。 谢谢

@echo off 
cls
echo Protecting NpAPIserver from crashes...
title NpAPIServer Watchdog

tasklist /FI "aplication.exe" | find /i "aplication.exe" 
for /f "tokens=2" %%x in ('tasklist ^| findstr aplication.exe') do set PIDTOKILL=%%x
IF ERRORLEVEL 2 GOTO KILLPROGRAM
IF ERRORLEVEL 1 GOTO LAUNCHPROGRAM

:KILLPROGRAM
taskkill /F /PID %PIDTOKILL%
goto LAUNCHPROGRAM

:LAUNCHPROGRAM
cd "c:\np"
start aplication.exe
goto WAITLUNCH

:WAITLUNCH
timeout /T 300
for /f "tokens=2" %%x in ('tasklist ^| findstr aplication.exe') do set PIDTOKILL=%%x
taskkill /F /PID %PIDTOKILL%
goto LAUNCHPROGRAM

1 个答案:

答案 0 :(得分:0)

(tasklist /FI "Status eq not responding"|find "lol.exe")&&rem not reponding
相关问题