tags:

views:

744

answers:

4

How do I best figure out if and where Apache is installed on a windows machine?

I'm writing a script that uses the installed apache, but sets up it's own config & server-root, and I don't want to hardcode it nor have the user explicitly set it (unless necessary).

I tried to search the registry, but couldn't find anything useful.

Update for those posting default paths:

On my machine, it was in C:/Program Files/Apache Software Foundation/Apache2.2. And if I had Vista 64-bit, it'd probably be under 'Program Files (x86)'. And if the computer doesn't have an English OS, it's even worse.

Workaround:

Guess I have to check %PROGRAMFILES% for Apache 2.0 or 2.2's default path, then fall back to a prompt. It's be nice to read the registry and find out exactly where it is.

I can't really beleive I'm the first one who wants to solve this properly? :)

+2  A: 

http://stackoverflow.com/questions/304319/is-there-an-equivalent-of-which-on-windows

vartec
Works if httpd.exe is in the path, but I'm not sure it is? (Will check tomorrow)
Marcus Lindblom
It's not in the path, so this won't work.
Marcus Lindblom
A: 

On Windows it is installed in c:/Program Files/Apache Group/Apache2/bin/Apache.exe

Rest of the directories (conf, log, doc-root, etc) are under c:/Program Files/Apache Group/Apache2

David Rabinowitz
yeah, if you follow the Qick Installation route when installing Apache, this is where it'd go by default. but I think this isn't a solution to marc's problem.
Peter Perháč
A: 

Not really an answer, but if I were you, I'd only use the default path (%PROGRAMFILES%\Apache Group\Apache2\bin\Apache.exe) or a couple of relatively safe default paths, and prompt if the executable was not found.

Otherwise it might pick up a completely unexpected installation. I hate programs that are "too smart".

Jaka Jančar
Seems like this is the only way. The registry key in the doc does not contain the default ServerRoot as stated. :-|
Marcus Lindblom
A: 

I hadn't installed Apache for all users on my machine, hence no registry key. But if one does that, it's located here:

HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Apache\2.2.xx\ServerRoot
Marcus Lindblom