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

Batch file 使用.bat检测崩溃的应用程序,batch-file,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"

大家好,可以用.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

这有用吗
tasklist/FI“Status eq not response”
谢谢,但它的查找所有崩溃的应用程序,但我只需要检查一个应用程序,如lol.exe也使用
/im
图像过滤器
(tasklist /FI "Status eq not responding"|find "lol.exe")&&rem not reponding