Windows - Take control of your Apache and MySQL startup with batch file

As default, Apache and MySQL are loaded automatically when windows start if you install it on your windows box. Some computer with less memory will have trouble with their start up time caused by many application windows call upon starting up including Apache and MySQL.



If you are web designer and your computer not as a web server, you may want to set Apache and MySQL start up by manual (unless your computer are set for a web server), by change it to manual at windows services will increasing windows start up time a little bit, but you will have to start the Apache and MySQL manually every time you want to use it.


You can go directly to windows services or can write a command line in a dos prompt for starting Apache and MySQL.

dos command:
service start apache2 <--- starting Apache service start mysql <--- starting MySQL service stop apache2 <--- stopping Apache service stop mysql <--- stopping MySQL Now what we can do is create a bath file to take control of Apache and MySQL start up in one step command. Open notepad and write this code. @echo off
IF %1 == stop GOTO STOP
IF %1 == start GOTO START
:START
net start mysql
net start apache2
GOTO END
:STOP
net stop mysql
net stop apache2
GOTO END
:END

Now save the code with .bat extention (i.e. www.bat) on windows root directory (c:\). Next test the code in command promt or you can go to START --> RUN and write this command:
c:\www start
c:\www stop

Note www is an example, depend on the name you give to the bath file. Now in the next time you want to start or stoping apache and MySQL you just write those command in START --> RUN menu.