Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I run an app from the DOS Prompt in Windows, the command in question is often not in the current directory, but is found via the PATH environment variable. What's the quickest way to find the path of the actual EXE that's being run?

share|improve this question
"path" gives you a list, you could check each manually. Though don't absent mindedly hit ; before return, or you might have to spend 10 minutes rebuilding your path, like I just did >_< – Phoshi Sep 3 '09 at 9:17
up vote 6 down vote accepted

On Vista you can type the executable's name in search field in start menu, when it's displayed in results, r-click and select "Open file location" from menu.

If the program is still running and you are using Process explorer from Sysinternals you can r-click on executable in the the processes list and select properties. In the Image tab you have path to the executable.

Another way is to use Windows Powershell, use command "get-command executable" without quotes and you will get path for the executable you are looking for. Shortcut for the command is gcm, so use like this "gcm calc"

share|improve this answer
Accepting this answer, as it directly addresses my question. The Powershell approach seems like the quickest way too. :) Unfortunately... I want to find the path of an EXE after running a separate DOS batch file that modifies the PATH environment variable. In Powershell, running the batch file requires a separate cmd.exe to be run, which means the PATH in Powershell is unaffected and so my target exe (tf.exe) still can't be located. Still, I should've said that in my question. Just didn't think it was important at the time. :-/ – Mal Ross Sep 3 '09 at 10:32
Using the taskmanager in Windows 7 (maybe Vista too), you can also right-click the process and choose "Open File Location". You don't need to install 3rd-party software like process explorer for this. If you know the processname, you can also type get-process processname | % { $_.path } to find the executable-path. However, this works not for every process. I haven't found the rule for that yet... – wullxz May 23 '12 at 20:55

If you have cygwin installed, you could always use the 'which' command

C:> which notepad
share|improve this answer
nice. but try "which dir"... – nik Sep 3 '09 at 9:27
+1, I do like the idea -- just that it needs a unix environment. You can also use the UnixUtil binary. – nik Sep 3 '09 at 9:39
There are several which implementations floating around which run without the Unix subsystem – Xetius Sep 3 '09 at 9:43

Try the following:

@rem file which.bat (must be placed somewhere in %PATH%)
@for %%e in (%PATHEXT%) do @for %%i in (%1%%e) do @if NOT "%%~$PATH:i"=="" echo %%~$PATH:i

When you type which notepad in commandline (cmd.exe):

C:\>which notepad
share|improve this answer
doesn't work... – Chazt3n Nov 16 '15 at 13:21
@Chazt3n It sounds unfounded at the moment. Please, explain how do you use? – Orient Nov 17 '15 at 4:01

If you're asking about a program currently running, Windows doesn't offer anything out-of-the-box for the command line, as far as I'm aware, that gives you the full path of the executable.

If you're asking about a program that you are able to invoke at the command line, then you can use the where command:

C:\> where fsutil


This works for all programs that you can invoke in your current PATH variable or the current working directory. It won't detect built-in commands such as DIR, but that's to be expected.

share|improve this answer
As a side note, the where tool isn't included by default for Windows XP or earlier. I believe Microsoft started including it with Vista or 7, but I don't have either one available to confirm. – Jesse Apr 3 '15 at 20:55

You could try

CD \
dir /s command.*

or from explorer just do a search for the command name.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .