I have a software that multiple users on a terminal server use and I am trying to create a bat file to kill a specific process when becomes non responsive. Here is the scenario. At any given time i could have 40+ users logged in all using a process [wrun32.exe] but it sometimes it will hang at 25% processor utilization. Needless to say if four users have processes the server is locked up. I created the following script to find the hung process and send its process ID as a variable that i can use taskkill to close.
::Kill WRUN ON SERVER01
for /f "usebackq tokens=2" %%a in (`tasklist /s SERVER01 /FO list /FI "IMAGENAME eq wrun32.exe" /FI "STATUS eq NOT RESPONDING" ^| find /i "PID:"`) do set PID=%%a
IF %PID%=NUL GOTO END Else taskkill /F /S SERVER01 /pid %PID%
I need to find a way to get this to only run on a process that is hung with the CPU utilization at 25% and run every 5 minutes. Any suggestions?