Detecting a Non-Responding Application

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Detecting a Non-Responding Application

#1 Post by mohdfraz » 08 May 2014 07:22

Hi,

a) Can we identify Non Responsive/ crashed applications using Batch file? If yes then how?
I want to run a email alert command if my desired application crashes.


b) Is there any way to Ping applications like we can ping web sites?

Thanks

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Non Responce Applications

#2 Post by foxidrive » 08 May 2014 07:58

tasklist can provide details about a non-responsive task:

Code: Select all

    Filter Name     Valid Operators           Valid Value(s)
    -----------     ---------------           --------------------------
    STATUS          eq, ne                    RUNNING | SUSPENDED
                                              NOT RESPONDING | UNKNOWN

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Non Responce Applications

#3 Post by mohdfraz » 08 May 2014 08:21

foxidrive wrote:tasklist can provide details about a non-responsive task:

Code: Select all

    Filter Name     Valid Operators           Valid Value(s)
    -----------     ---------------           --------------------------
    STATUS          eq, ne                    RUNNING | SUSPENDED
                                              NOT RESPONDING | UNKNOWN


How did you generated that?

I tried this code

Code: Select all

Tasklist >c:\List.txt
and this result came



Image Name PID Session Name Session# Mem Usage
========================= ====== ================ ======== ============
System Idle Process 0 Console 0 28 K
System 4 Console 0 240 K
smss.exe 828 Console 0 388 K
csrss.exe 876 Console 0 7,048 K
winlogon.exe 908 Console 0 1,716 K
services.exe 952 Console 0 4,664 K



Awaiting

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Non Responce Applications

#4 Post by foxidrive » 08 May 2014 08:49

Code: Select all

tasklist /?

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Non Responce Applications

#5 Post by mohdfraz » 08 May 2014 09:36

foxidrive wrote:

Code: Select all

tasklist /?


Yes, I noticed after replying to you. But can you make a code to check status for example note.exe and if not responding then run a command other wise go to Loop.

Thanks

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Non Responce Applications

#6 Post by mohdfraz » 08 May 2014 09:50

foxidrive wrote:

Code: Select all

tasklist /?



ok this code can check notepad.exe status running. But if its status become other than "running" i want to run another command and if status is "running" then go to loop. how i can do this?

Code: Select all

tasklist /fi "imagename eq notepad.exe" /fi "STATUS eq running" >c:\test.txt

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Non Responce Applications

#7 Post by foxidrive » 08 May 2014 09:54

This should launch run.exe when note.exe is not responding.

Code: Select all

tasklist /FI "IMAGENAME eq note.exe" /FI "status eq NOT RESPONDING" 2>&1 |find ":" >nul || run.exe

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Non Responce Applications

#8 Post by mohdfraz » 08 May 2014 10:04

Great,,, Thank you,,,,,

I write this one,, I think this will work as well.

Code: Select all


:Loop

tasklist /fi "imagename eq notepad.exe" /fi "STATUS eq running" goto SkipAlert

:: command to run here if program not equal to Status "Running"

msg * Program not responding


:SkipAlert

GoTo :Loop


mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Non Responce Applications

#9 Post by mohdfraz » 09 May 2014 05:58

Foxidrive, your codes is working. Mine is not. I will use yours.

Code: Select all

:loop
tasklist /fi "imagename eq notepad.exe" /fi "STATUS ne RUNNING" |find "." >nul && goto 1Alert
goto loop

:1Alert
Msg * Start Alert Not Responding program
pause


Thanks

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Non Responce Applications

#10 Post by mohdfraz » 09 May 2014 07:55

One problem Tasklist find if note.exe is in the list and if any other program having Not Responding status then it run.exe

Is there a way to tell Tasklist to check Not Responding Status for note.exe only and if its not responding then run.exe

Thanks

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Detecting a Non-Responding Application

#11 Post by foxidrive » 09 May 2014 07:57

How did you test that?

I assumed the filters were ANDed.

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Detecting a Non-Responding Application

#12 Post by mohdfraz » 09 May 2014 08:02

foxidrive wrote:How did you test that?

I assumed the filters were ANDed.



I run this code and it show me that there was some other Not Responding application running which triggering Alert and it is not monitoring my specific required application. Is there any way? Do not know what is ANDed means.

Code: Select all

:loop
Tasklist /FI "IMAGENAME eq MessageCenter.exe" /fi "STATUS eq NOT RESPONDING" |find "." >nul && goto StartAlert
goto loop

:StartAlert
Tasklist /fi "STATUS eq NOT RESPONDING" >>c:\NotResponding.txt

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Detecting a Non-Responding Application

#13 Post by foxidrive » 09 May 2014 08:09

mohdfraz wrote:

Code: Select all

Tasklist /fi "STATUS eq NOT RESPONDING" >>c:\NotResponding.txt


This line is going to show you EVERY non responding program. That's what it is being told to do.

I don't understand what you are doing, or what you want to do, and how you are including it into your code.

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Detecting a Non-Responding Application

#14 Post by mohdfraz » 09 May 2014 08:14

foxidrive wrote:
mohdfraz wrote:

Code: Select all

Tasklist /fi "STATUS eq NOT RESPONDING" >>c:\NotResponding.txt


This line is going to show you EVERY non responding program. That's what it is being told to do.

I don't understand what you are doing, or what you want to do, and how you are including it into your code.



Right, I am using the list to identify issue, But I really want that if MessageCenter.exe becomes Not Responding status then execute Run.exe ,,, Is there any way to do this using?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Detecting a Non-Responding Application

#15 Post by foxidrive » 09 May 2014 09:58

You already have that code. How does it fail?

Post Reply