Restart XAMPP without using the Control Panel

I use XAMPP to run several local development environments. For the last few years I've been using an AutoHotKey script that lets me launch the XAMPP Control Panel with a keypress. While this is reliable enough, every time I press the key a new instance of the Control Panel is opened, regardless of how many are already open and regardless of it's whether opened programmatically or manually.

This results in a situation in which there are multiple instances of the XAMPP Control Panel running at any one time, and I have a feeling stopping and starting Apache and MySQL from these multiple control panels is resulting in database corruptions like this one, which occurs every few months.

How can I automate the process of restarting my servers while avoiding opening the Control Panel several times?

1 Answer

I decided that the simplest and fastest way to do this was to do away with the GUI of the XAMPP Control Panel entirely.

The following AutoHotKey script will check if XAMPP is running: if it isn't, it will start the server. If it is, it will restart the server. In other words, it will always ensure that XAMPP is on.

I designed the script in this way instead of as a toggle to both start and shut it down because it's more crucial for me that I can quickly restart the server with just one press of a key, and I've never noticed any side effects of powering down my machine while XAMPP was running.


Start and restart the server with a single keypress

Remember to replace the NumpadEnter key with your hotkey of choice.

NumpadEnter::
Process, Exist, httpd.exe
If ErrorLevel = 0 { Run, C:\XAMPP\apache_start.bat,,Hide Run, C:\XAMPP\mysql_start.bat,,Hide }
Else { Run, C:\XAMPP\apache_stop.bat Run, C:\XAMPP\mysql_stop.bat Sleep, 2000 Run, C:\XAMPP\apache_start.bat,,Hide Run, C:\XAMPP\mysql_start.bat,,Hide }
Return

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like