When we start the Apache in windows machine httpd.exe start its process.
Now we can determine if httpd.exe process is running or not using this command:

query process httpd.exe

This will return something like this:

 >system         services         0    3340   httpd.exe
 >system         services         0    4720   httpd.exe

Now, is it possible to get the location of the httpd.exe by using windows command in the cmd?
The command should return this (location of httpd.exe):

E:\Installed Softwares\wamp\bin\apache\apache2.4.9\bin\httpd.exe
  • We can get the running process list using TASKLIST command. For finding the location of the process, we can use process explorer. – vembutech Dec 31 '14 at 4:43
  • Thanks, but thats not what i am looking for – rakibtg Dec 31 '14 at 4:57

I am not sure that I get you, but if you want to locate file in CMD you can use where comand (it searches only in current directory and in path ) But you can put some parameters. For example If I search for java.exe

Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\Administrator>where java.exe
C:\Program Files\Java\jdk1.6.0_26\bin\java.exe

edit: You should try to search recursive and it will give you location, but it have worked for me only if file was on same partiton.

C:\Users\Administrator>where /r c:\ thunderbird.exe
c:\Program Files\Mozilla Thunderbird\thunderbird.exe
| improve this answer | |
  • Thanks, but i want to get the location of the software that is already running and can be view from the task manager as well. – rakibtg Dec 31 '14 at 10:36
  • Nope, "where" is not working – rakibtg Dec 31 '14 at 10:42
  • "where" is like the UNIX command "which". It looks for the file in the PATH, unless you specify the /R switch - which is much the same as doing dir httpd.exe /S. – Adam Thompson Dec 31 '14 at 13:01

You can do this using WMI.
We need to construct a WQL query for processes which are called httpd.exe, and we want to get the path from which the executable was launched.
This information is kept in the Win32_Process class, and the documentation shows us which bits of information we need to provide (eg Name), and which bits to ask for (eg ExecutablePath).

We can use wmic.exe to query WMI like this:

wmic process WHERE name="httpd.exe" GET ExecutablePath  

This should output something similar to:


You might want to get the CommandLine, instead of the ExecutablePath, as this will also tell you which command line arguments the process has been launched with, and this can make a big difference when you're narrowing down which processes are doing what:

wmic process WHERE name="httpd.exe" GET CommandLine  

This should show you something like:

C:\Apps\httpd.exe -config=E:\widgetsales\httpd.conf
C:\Apps\httpd.exe -config=E:\widgetservices\httpd.conf
C:\Apps\beta-test\httpd.exe -config=D:\DevStuff\httpd.conf  

We can do even better, by getting the PID as well as the command line:

wmic process WHERE name="httpd.exe" GET CommandLine, ProcessID 

CommandLine                                                    ProcessId
C:\Apps\httpd.exe -config=E:\widgetsales\httpd.conf            51064
C:\Apps\httpd.exe -config=E:\widgetservices\httpd.conf         24716
C:\Apps\beta-test\httpd.exe -config=D:\DevStuff\httpd.conf     52728  
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.