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?
source to share
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.
source to share