How can I automatically catch and restart the crashed process on Windows?
It might be silly. When my process crashes, WerFault.exe was launched and I can only regain control after I close this window or kill its task.
I'm looking for an easy way to prevent a broken program from showing this window or any idea for me to catch this disaster.
SEH, by the way, is not useful. I do not know why. The crash also persists when I use SEH.
Thank!
Now I'll just figure out how to avoid this WerFault.exe and sometimes csrss.exe window and get back control.
source to share
Use the Application Recovery and Restart API to restart Windows Error Reporting (WER) and recover your application if it crashes. Use RegisterApplicationRestart()
to register your intent for a restart. Use RegisterApplicationRecoveryCallback()
to register your intention to save and restore state data.
source to share
I have not tried this, but this api: WerAddExcludedApplication
should disable the troubleshooting: http://msdn.microsoft.com/en-us/library/bb513617%28v=VS.85%29.aspx
As for restarting your application, you can create another background process that will start your main process and check how it behaves. If it works, restart it.
[edit]
Unfortunately this api may not work as suggested in the comments to it - in order to remove this dialog you will need to FindWindow() and SendMessage(... WM_CLOSE...).
source to share