开发者

Robustly killing Windows programs stuck reporting 'problems'

开发者 https://www.devze.com 2023-01-02 01:51 出处:网络
I am looking for a means to kill a Windows exe program that, when being tested from a python script, crashes and presents a dialog to the user; as this program is invoked many times, and may crash rep

I am looking for a means to kill a Windows exe program that, when being tested from a python script, crashes and presents a dialog to the user; as this program is invoked many times, and may crash repeatedly, this is not suitable.

The problem dialog is the standard reporting of a Windows error:

"Foo.exe has encountered a problem and needs to close. We are sorry for the inconvenience"

and offers a Debug, Send Error Report, and Don't Send butto开发者_如何学编程ns.

I am able to kill other forms of dialog resulting from crashes (e.g. a Debug build's assert failure dialog is OK.)

I have tried taskkill.exe, pskill, and the terminate() function on the Popen object from the subprocess module that was used to invoke the .exe

Has anyone encountered this specific issue, and found a resolution?

I expect automating user input to select the window, and press the "Don't Send" button is one possible solution, but I would like something far simpler if possible


Wouldn't it be easier to disable the error reporting feature?


If you were to use CreateProcessEx or a WinAPI specific function, you might be able to call TerminateProcess or TerminateThread to forcibly end the process.

0

精彩评论

暂无评论...
验证码 换一张
取 消