Non-Responsive Program

Started by mjwillyone, August 16, 2021, 04:02:52 PM

Previous topic - Next topic

mjwillyone

Once in a while I have a windows program that I am going to use keystrokes, etc to run reports from that, when opened, reads "Not Responding" as part of the file name at the top of the open window (see attached image.)

Is there a way that Winbatch could test for such a state?

td

You could use the WIL CLR hosting and the FCL's "System.Diagnostics.Process" class.  The class has a "Responding" property that returns false(0) when the process UI is not responding.

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.responding?redirectedfrom=MSDN&view=netframework-4.8#System_Diagnostics_Process_Responding

Tomorrow I will try and set aside some time to put together an example unless someone beats me to it or comes up with a better idea.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl


td

To target a single application:

Code (winbatch) Select
; Load needed assembly and class
ObjectClrOption("useany","System")
objProcess = ObjectClrNew("System.Diagnostics.Process")

strText = "Firefox is OK"
strProcName = "firefox"   ; Process to check
aProcs = objProcess.GetProcessesByName(strProcName)

; Check all processes with the targeted name
nProcMax =  ArrInfo(aProcs, 1) - 1
for  i = 0 to  nProcMax
   if !aProcs[i].Responding()
      strText = "Found unresponsive process"
      break
   endif
next

; Do something with the newly gained information.
Message('FireFox Check', strText)
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

mjwillyone

Thank you, TD!

So, I would alter the strProcName to my own application and the strText to what fits.  Is that correct?  And, is the strProcName the window name or the title of the exe?

Mike

td

On newer versions of Windows MSFT has an in my opinion a rather strange way of identifying processes by name. Generally, but not always the name is the root name of the executable file that contains the application machine instructions. One way to check is to look for the application in Task Manager. That name will usually work if you don't include the parenthesis and contents after the name.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade