Find the path to the Apache server on windows

For Windows script I am writing, I need to detect if Apache 2.2 is installed on the machine and find the path to the application.

One solution I came up with is wget http: // localhost: 8080 / server-info and parse the root and config file from it. This will not work if the server is not using port 8080

Another option is to call "sc qc Apache2.2" and parse the returned string. This will not work unless the server is installed as a service or uses a different name.

Is there a better way to do this?

+1


source to share


2 answers


Not many great options if they didn't install it using the installer. If they used the MSI / installer program, you can check the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Apache\2.2.2\ServerRoot 
HKEY_CURRENT_USER\SOFTWARE\Apache Software Foundation\Apache\2.2.2\ServerRoot

      

You can also check the list of running processes:



WMIC PROCESS get Caption,Commandline,Processid

      

Find the corresponding EXE. If for some reason you need a port number, use netstat and find the corresponding port.

Also, when you say "windows script" I am assuming that you are using something modern and capable, like Windows Scripting Host (my favorite) or PowerShell . Don't even download batch files.

+2


source


As I recall, Apache writes some registry keys. If you know how to read them from a script, this might help.



0


source







All Articles