For a windows script I am writing, I need to detect if the machine has Apache 2.2 installed, and to find the application path.
One solution I came up with is to wget http://localhost:8080/server-info and parse the root and the config file from it. This would fail if the server does not use port 8080
Another option would be to call “sc qc Apache2.2” and to parse the returning string. This would fail if the server is not installed as a service, or is using a different name.
Is there any better way to do that?
Not a lot of great options if they didn’t install it using the installer. If they used the MSI/installer, you can check the registry:
You can also check the running process list:
Look for the appropriate EXE. If for some reason you needed the port number, then use netstat and search for the appropriate port.
Also, when you say ‘a windows script’, I am assuming you are using something modern and capable like Windows Scripting Host (my favorite) or PowerShell. Don’t even bother with batch files.