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

Is there an equivalent of the Unix whereis command in Windows?

So that I could figure out where commands I can run actually is.

share|improve this question
up vote 108 down vote accepted

The where command does what you want and goes back at least to the resource kit for Windows 98, and is included by default in Server 2003, Vista, and newer:

C:\>where csc

If executed with no arguments (on Vista), it results in one of my favorite messages:

ERROR: The operation completed successfully.

If executing in PowerShell, be sure to include '.exe' to distinguish from any 'where' aliases or scripts along the path. ('where' is a typical alias for Where-Object.ps1)

C:\> where.exe where.exe
share|improve this answer
Everyday I learn something new... – Rubens Mariuzzo Jan 25 '13 at 4:00
Kind of sad where just returns usage help now in Windows 7. Wanted to see it for myself :p – Svish Feb 6 '14 at 13:48
where not available in XP – Tom Roggero Feb 10 '14 at 1:55
@TomRoggero, I could have been more clear. It's part of the optional resource kit starting with Windows 98, and only included in the base install for version after XP. – Kevin Feb 10 '14 at 17:32

hackerish which.cmd:

@echo off
@set PATH=.;%PATH%

@rem about:  something similar like the unix-alike-which, but with
@rem         within pure cmd

if "%1" == "" (
    @echo Usage: 
    @echo   which 'cmd'
    @echo.if 'cmd' is not found, ERRORLEVEL is set to 1
) else (
    ( @for %%f in (%1 %1.exe %1.cmd %1.bat %1.pif) do if not "%%~$PATH:f" == "" ( @echo %%~$PATH:f ) else @set ERRORLEVEL=1) 
share|improve this answer
This is a good fix for older systems, but you should know that it results in a few quirks. It matches directories, only returns the first result found in the path for each extension, and should include every extension found in the PATHEXT environment variable. – Kevin Sep 11 '09 at 14:48
yah, this is a bit older hack of mine, when i pasted it here i instantly saw the potential for %PATHEXT% :) – akira Sep 11 '09 at 18:08

Please, use where command:

> where app.exe

It is the best way to achieve your goal.

You can also use PowerShell command:

> $env:path.Split(';') | gci -Filter app.exe

and expanded version looks like this:

 > $env:path.Split(';') | select -Unique | ? {$_ -and (test-path $_)} | gci -Filter app.exe
share|improve this answer
This is the best answer – skan Dec 19 '15 at 23:27

Somewhere "out there" I found this batch file whereis.bat:

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

Update: maybe I found it here.

share|improve this answer

There is at least a Windows port for the which utility.

share|improve this answer

A different (GUI) approach, but look at Everything.

share|improve this answer
That's something different. It definitely doesn't help you to answer the question "what executable is exactly executed, when I execute the <command> in the current directory" and that's what OP is asking. – Dawid Ferenczy Jun 23 at 12:21

I was searching for this today and since I'm on XP without the resource kit, I turned to powershell with the following command:

dir -path c:\ -filter ffmpeg.* -r
share|improve this answer

You can try searching for the command using the following:

dir /s type-whatever-you-are-searching

share|improve this answer
This does not work for me. For example, the exp command is in my path, but dir/s exp or dir /s exp.exe just gives "File Not Found". – bobmcn Sep 10 '09 at 21:12
This would work if a) you search from the root of the drive, b) your path is all on one drive, and c) your path is in lexicographical order. Even under these conditions it will be ridiculously slow. – Kevin Sep 10 '09 at 23:09

You must log in to answer this question.

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