How can I automatically restart mGalaxy (MAME) if it crashes?
I fixed up an old arcade cabinet my office has and everything is working just trying to out the finishing touches on it.
The cabinet is hooked up to a Windows 7 machine running MAME. I am using mGalaxy as a front end for MAME and looking for a way to relaunch the mGalaxy.exe
if it crashes or a user quits the app.
I have tried a few different solutions and can't get them to work right.
I tried Process Alive but it doesn't remember the settings after I restart the computer. I also tried Restart on Crash however this would open the app multiple times even when the app was already running.
Does anyone have experience with theses apps and know if there are settings I am missing? Is there another option to do what I want?
Solution 1:
You could create a batch file that automatically starts the application, and if it stops, to start it again. Instead of running the program, you would run this file instead.
@Echo off
:Start
mGalaxy.exe
echo Program terminated at %Date% %Time% with Error %ErrorLevel% >> c:\logs\program.log
echo Press Ctrl-C if you don't want to restart automatically
timeout 10
goto Start
Core concept of this batch borrowed from SuperUser. Some edits mine.
Here's what each line does:
-
@Echo off
- Stops the command prompt from repeating every command -
:Start
- This is a marker. We'll use this later to jump back to this point. -
mGalaxy.exe
This starts the application, and waits for it to finish/quit.- Note that this assumes that the application is in the same folder as your new batch file. If you want to keep the batch file elsewhere, you will need to add a folder path to this - Something like
"C:\Program Files\MAME\mGalaxy.exe"
- Note that this assumes that the application is in the same folder as your new batch file. If you want to keep the batch file elsewhere, you will need to add a folder path to this - Something like
-
echo Program terminated at %Date% %Time% with Error %ErrorLevel% >> c:\logs\program.log
- This is just a bit of logging if you want to figure out how often it crashes and potentially debug the possible cause. You can remove this if you wish -
echo Press Ctrl-C if you don't want to restart automatically
- This outputs a reminder on how to quit the application (so you don't forget!)
-
timeout 10
- pauses the batch file for 10 seconds, giving you time to quit it before the application starts up again. -
goto Start
- Returns the program to the 'Start' marker, effectively looping forever.
To create this batch file, open up Notepad, paste these commands, and Save as type 'Batch File (.bat
)', rather than .txt
.