Server Fault is a question and answer site for system and network administrators. 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

The Unix which statement is very useful in determening which path is used for program run from the command line, and it would be very helpful to have something similar in windows.

share|improve this question
Post up on and maybe somebody would write one for you. :-) I imagine it'd be fairly trivial. – Brian Knoblauch Jun 3 '09 at 19:54
up vote 8 down vote accepted

Save this to a file named which.cmd:

@for %%e in (%PATHEXT%) do @for %%i in (%1%%e) do @if NOT "%%~$PATH:i"=="" echo %%~$PATH:i
@for %%i in (%1) do @if NOT "%%~$PATH:i"=="" echo %%~$PATH:i

Or download UnxUtils - they have lightweight native ports of the most common tools.

Or if you don't care about lightweightness, install Microsoft Services For Unix. Yes, it has Microsoft Vi.

share|improve this answer
Microsoft Vi: – Josh K Jun 4 '09 at 4:35
Or install cygwin – ringø Oct 11 '10 at 0:55

I use whereis written by Joseph M. Newcomer (co-author of Win32 Programming).

share|improve this answer

Nope, no native equivalent. Can't even get command completion with ^F in a cmd /f:on shell, more's the pity.

You can always install a Windows port of a Unix shell environment to get which, of course.

share|improve this answer
Did you try pressing the Tab key for completion? – grawity Jun 3 '09 at 20:01
No, since that's not a Windows cmd.exe completion character, and it doesn't do anything... – chaos Jun 3 '09 at 20:12
Strange, I always used Tab for tab-completion, it worked even on fresh installs. – grawity Jun 3 '09 at 20:16
...though I'm not sure now what /f does. (My phone doesn't have cmd.exe) – grawity Jun 3 '09 at 20:17
Check cmd /? when you have it on hand. It goes on for a while about how it enables ^F for file completion and ^D for directory completion, and how to tweak it. Wish I knew how to turn out this tab completion. :) – chaos Jun 3 '09 at 20:39

You have this with PowerShell. If you don't have PS you can get it from Microsoft. It's free.

Here is an article from Linux-Magazine which touches on the topic of Unix (bash) commands available in PowerShell.

share|improve this answer

Windows Server 2003/2008 has "where" built in.

share|improve this answer
...or is it in the Reskit/Support Tools. No, I'm sure it's in CMD.EXE... – Simon Catlin Oct 10 '10 at 20:52

And if your program is interactive you can always check the Task manager. Select the process you want to explore, and choose "Open file Location" from the popup meny

share|improve this answer
I'm sorry, but this does not answer the question being asked. This only provides the path of a running file. The question is asking to find what executable will get called when a command without a path is executed. – Caleb Apr 20 '11 at 10:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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