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?
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 (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.
not a better idea, but could probably adapt this to CLR:
https://techibee.com/powershell/powershell-find-applications-in-not-responding-state-in-task-manager/2226
To target a single application:
; 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)
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
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.