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 :

605 Responses to “Automatically Restart Crashed Or Hanged Applications”

  1. Enoch Bryant says:

    I tried that, but it kept restarting the bat file and not running it even though it properly runs outside of restart on crash. I even tried to convert the .bat file to a .exe, but same result.

  2. Enoch Bryant says:

    I already tried that, the bat file just restarts over and over

  3. Jānis Elsts says:

    Hmm, that’s weird. Did you set the .bat file just as the command to execute, or also as the application to monitor? It should only be the command, the “monitor this application” field should still be the actual .exe.

  4. Enoch Bryant says:

    Ok, thanks for the tip, that worked. I had to set my .bat file to

    stransmit-rendezvous-GRE.exe” -s:1000 “udp://127.0.0.1:9009” “srt://172.28.1.224:9500?mode=rendezvous&latency=6000&conntimeo=10000” -r:1>C:\Tools\SRT\log.txt

    Then select the .exe as the file to monitor and set the .bat file only in execute a command, I now have a log file. The only thing to figure out now is how to send to cmd window and log file. With the above setup, I only have the -v in the log file

  5. Jānis Elsts says:

    I think there are ways to do that with PowerShell scripts, but I’m not very familiar with it. See this SO thread for example:
    https://stackoverflow.com/questions/1215260/how-to-redirect-the-output-of-a-powershell-to-a-file-during-its-execution

  6. Nick says:

    Can you open source this or fix the CPU issue? I have a new PC and this constantly uses about 12% CPU monitoring 20 processes.

  7. Jānis Elsts says:

    I’ve just uploaded a new version that should have noticeably better performance when monitoring many applications at once. Please give it a try.

  8. Peesjee says:

    FYI,

    if there is a new version of Restart-On-Crash i can simulate a crash:

    1. Start RoC (that already has the new ‘detection’ system that there is a new version available)
    2. A new popup appears telling there is new version (but not in foreground, so i had first missed this) -> don’t click ‘Get Update’
    3. doubleclick on the icon in the right-bottom corner -> Crash!

    Greetz
    Pieter

  9. ExCo says:

    When I attempt to download the new update, the page goes blank before the following error is displayed:

    Your connection is not private

    Attackers might be trying to steal your information from 1.shadowcdn.com (for example, passwords, messages, or credit cards). Learn more

    NET::ERR_CERT_COMMON_NAME_INVALID

    What is the problem?

  10. Jānis Elsts says:

    That looks like some kind of a problem with the SSL certificate on the CDN domain. Try this download link instead:
    http://w-shadow.com/files/RestartOnCrash-v1.6.zip

  11. jianhc says:

    Very useful tool! Thank you so much!

    Wrote a recommendation in Chinese:
    https://jianhc.blogspot.com/2019/01/pimebug4.html

  12. Cameron says:

    This is a Great App thanks for it and keep up the good work.

    I cant get this app to startup after crash. This is in the log.

    06/02/2019 Wednesday 13:08:10 Executing a command : “C:\Program Files\Blue Iris 4\BlueIris.exe”
    06/02/2019 Wednesday 13:08:10 CreateProcess error : The requested operation requires elevation

    Thanks Again.

  13. Jānis Elsts says:

    It sounds like you might need to have admin permissions to run that application. Try starting RoC as an administrator.

  14. Cameron says:

    Thanks Janis That did it.

    I will have to remember that one.

  15. David says:

    RoC doesn’t seem to work on Win7 or 10, is this a known to be true situation?

  16. Jānis Elsts says:

    I’m on Windows 10 myself and I haven’t noticed any compatibility issues. Can you provide any more information about the problem(s) you’re having? Do you get an error when you try to start RoC or something else?

  17. Echo says:

    Hi. Is there any possibility, an alternative method of application crash detection, to make it working with CLI applications?

  18. Jānis Elsts says:

    In many cases, it is already possible to use RoC with CLI applications. If you tried it and it didn’t work, could you tell me about the problems that you encountered? For example, did you see any error messages?

  19. Echo says:

    CLI application gets crashed with error code “c0000005”, but status in RoC still remains “Running”.

    Prior to using RoC i’ve written my script with SendMessageTimeout function, it didn’t work with CLI applications also.

    Today i’ve managed to find a temporal solution with help of API – NtQuerySystemInformation function, SYSTEM_PROCESS_INFORMATION and SYSTEM_THREAD_INFORMATION structures, where value of “WaitReason” flag of main thread changes to “UserRequest” when CLI application crash occurs. This is not good solution and might be inappropriate in some cases, but it works in my current case, and is the only option i have at the moment.

    Hopefully future RoC versions might provide better solution for such cases, if it’s possible.

  20. Daniel says:

    Hi,

    Is there anyway that when an app is re-opened it is minimized?

Leave a Reply