Automatically Restart Crashed Or Hanged Applications

Don’t you hate it when programs hang or crash? I find it especially annoying when a background application like an IM client or a bandwidth monitor silently crashes – sometimes I only notice the problem hours later when I’ve already missed a bunch of messages. I’m sure you’ve encountered a few “Not responding” errors and some irritatingly crash-prone applications yourself.

If you have an unstable program that you absolutely need to run at all times, but don’t want to waste your time monitoring and manually restarting it every time it croaks, I might have something interesting for you.

Restart on Crash is an monitoring tool that will watch the applications that you specify and automatically relaunch any program that hangs or crashes. You can add any number of applications to monitor, enable/disable them individually and edit the command line that will be used to restart an application.

Restart on Crash doesn’t require installation and stores all it’s configuration data in a “settings.ini” file in the program’s folder, so it’s portable. It should be compatible with most NT-based Windows versions.

Download Restart on Crash (1.4 MB)

Screenshots & Documentation

Main application window

The main window

  • To add a new application to monitor, click the “Add” button or press the Ins key.
  • To delete on or more applications from the list, select them and click “Delete” or press Del.
  • To edit the per-application configuration, double-click the corresponding row. This will open the editing dialog (see below).
  • You can also access the RoC configuration by clicking “Settings” and view the activity log by clicking “Show Log”. The log contains information about crashed/hanged applications, executed commands, and so on.
Editing the monitor settings for an application

Editing the monitor settings for an application

Well, this one should be pretty self-explanatory 🙂 One detail to keep in mind is that enabling the “It isn’t running” option will make Restart On Crash treat the application as if it has crashed even if you have purposefully it closed it. You can get around this by disabling the monitoring of the application before you close it.

The configuration dialog. Yes, that's it.

The configuration dialog. Yes, that’s it.

“Grace period” is how long Restart on Crash will wait before trying to terminate/restart an application that it has just terminated/restarted. This is intended to prevent a scenario where RoC kills a hanged program, restarts it, decides it has hanged again (e.g. if the program is non-responsive while starting up) and wrongfully terminates it again.

Known Issues

  • If you configure RoC to automatically kill a hanged application, it will terminate all instances of that application when doing so. This may be fixed eventually.

Release Notes

2022-11-02

  • The “execute a command” feature can now launch shortcuts (.lnk files). Potentially, it can now run almost any type of file as long as file associations are set up correctly.

2019-12-17

  • Improved “application is not responding” detection.
  • Added a “Clear Log” button to the Log window.

2019-08-24

  • Added a “Restart Now” option to the application pop-up menu. It restarts the selected application immediately without waiting for the grace period to expire.
Related posts :

620 Responses to “Automatically Restart Crashed Or Hanged Applications”

  1. Jānis Elsts says:

    There are two things that RoC does to check if an application is responding:

    1. It sends one of the application windows a WM_NULL message with a 500 millisecond timeout. If the window does not process the message within the timeout, it is treated as “not responding”.

    2. If #1 works fine – that is, the application seems to be responding – RoC also uses the IsHungAppWindow Win32 API function to check if Windows thinks the application is not responding. See the link for more details about how that works. If the function returns “true”, RoC will treat the application as “not responding”.

    RoC does not take CPU usage into account at all.

    To kill an application, RoC uses a library method that (I think) calls TerminateProcess under the hood. This is a forceful way to stop an application. This approach was intentionally chosen because frozen/not responding applications might not react to more tactful solutions such as sending a WM_CLOSE message.

    Most likely, your app would not get a chance to log anything.

  2. Revo says:

    What is the option “Wait N seconds and double check”? What is its purpose?

  3. Jānis Elsts says:

    When the option is enabled and RoC detects that an application has crashed, it won’t immediately try to stop/restart the application. Instead, it will wait a short time – that is, the configured number of seconds. Then, if the application still looks like it has crashed, RoC will try to restart it.

    This is useful for applications that sometimes freeze for a while but then start working again later.

  4. Gumby says:

    Hi Janis,

    Thanks for RoC; been using it for years. Would you consider adding support for shortcut (.lnk) files to execute after a crash is detected? Shortcuts grant the ability to minimize a re-opened program while it could also be used to launch a (.vbs) batch script. As of v1.6.3.2, neither filetype is supported.

    An example of a helpful (.vbs) batch script would be to re-open the crashed program, while also running a second program that removes phantom icons that are left behind by RoC (via RefreshNotificationArea.exe). Logitech Gaming Software and USB Disk Ejector are two programs that leave phantom icons when forced to close by RoC. Having to wave the mouse over the systray to make them disappear manually isn’t a big deal, but it becomes a nuisance after hundreds\thousands of swipes, so a solution would really be nice.

    CMD batch files (.bat) *do* work, but CMD scripts always show a popup window when running, whereas (.vbs) scripts run quietly in the background, which is a much cleaner solution.

  5. Jānis Elsts says:

    I’ve rewritten the part of the code that executes commands and it should now be able to launch shortcuts. Hopefully, I didn’t break other kinds of commands in the process. Please give it a try.

  6. Gumby says:

    Thanks for adding .lnk support, Janis. Windows shortcuts now work as they should. I can now run command windows minimized and am no longer required to use a .bat to launch a .vbs script. RoC is literally perfect now.

  7. Vlad says:

    Thanks for the app. Unfortunately, it has bug that sometimes it doesn’t see that app crashed and doesn’t restart it even though the app is not present in the taskmgr process list.

  8. Jānis Elsts says:

    Unfortunately, that doesn’t seem to happen with any of the apps that I have tried, so I can’t really tell what’s causing that problem or how to fix it. It could be something that’s specific to a particular application.

  9. DJ says:

    Brilliant in its simplicity; does exactly what we need it to do. Thank you for sharing this!

  10. Nahrain says:

    Thanks for the app, but can we remove or disable the icon from the system Tray?

  11. Jānis Elsts says:

    At the moment, there is no built-in way to remove the RoC icon from the system tray.

  12. […] bajar Restart On Crash en su PC, conéctese a ella lugar página oficial y realice click en el link Descarga el CV del incidente. Cuando se complete la descarga, extraiga […]

  13. Travis says:

    Anyway not to have the settings file open and display on reboot? Absolutely loving this besides that.

  14. Jānis Elsts says:

    Do you mean the RoC window itself? In theory, the “start minimized” option in the settings screen should hide it on startup, but in practice there’s a known bug that may prevent that from working.

    On the other hand, if the settings file is part of an application that you’re starting with RoC, there’s currently no built-in way to hide it. I guess you could try making a shortcut that runs the target application minimized and then starting that shortcut with RoC instead of having it run the application directly.

  15. Travis says:

    Its a .ini file that opens each time the computer logs in. I can send you a picture if there is an email I can send it to. It appears to be a notepad with the settings for the application I am telling it to Restart on Close. But it also has general settings as well. I just do not want to confuse the user on what it is. It is a shared work PC and want to minimize confusion.

  16. Jānis Elsts says:

    My email is on the contact page, you can send it there if you like.

    RoC also has an .ini configuration file, but that file is not supposed to ever just open on its own. If that’s the file you’re seeing, there might be something weird going on.

  17. elliot says:

    can you add support for if file is not modified after x minutes to restart the application? i sent this on contact page too. some more info on it

  18. Jānis Elsts says:

    That’s an interesting idea, though it sounds like it could be a niche feature. I’ll add it to the list of potential improvements.

  19. Anthony says:

    HI:

    Thanks, great app.
    Is RoC still effective after Windows logout.
    If not, how to have RoC effective when Windows was logout.

    Thanks you so much.

Leave a Reply