is there a smart way to re-run an app?

Hi Guys,
when my app has an unhandled exception I do this

create a file called abc.txt and write app.ExecutableFile.AbsolutePath to it

I create another file called abc.bat and write
Start “” “runME.exe”

I then create a shell to run abc.bat where f points to abc.bat
mySHELL.Mode = 0
mySHELL.TimeOut = 1000*30
myShell.Execute f.AbsolutePath

I then QUIT the crashing app

runME.exe is a small XOJO desktop app to read the path of the sending APP to a folderitem f.
It waits a few seconds and then it LAUNCHes the folderitem


This works fine but is there a nicer way where there is no need for the external app?

Keep in mind this is for Console and WEB apps as well.
So you cannot use Launch

I have tried a BAT to run a BAT both with delays of a few seconds and even though the crashing APP does close the newly run version of the app will start it then immediately closes.

Has anyone figured something out?


Would it not be better to find why you are getting the exception, or at least to code around it in the main program?

yes it would however if something happens at 4am and our servers are critical it is better to have the system running and then look at the cause in the morning obviously.

Fair enough. An idea is to put a mutex in ( so the program will quit if already running ) and use the Windows Scheduler to run it repeatedly. Or have 2 copies of the app and a means to distinguish them, and flip between them on crash ie: run the ‘other’ one.

I think Windows Services can start a crashed app if I’m not mistaken?
Or use something like a service watcher.

Windows services can be configured to restart automatically if they fail. The easiest way to configure this is to run services.msc and set the recovery properties of the service.