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

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

link|improve this question

68% accept rate
feedback

6 Answers

up vote 18 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
C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe

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

C:\>where
ERROR: The operation completed successfully.
link|improve this answer
feedback

hackerish which.cmd:

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

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

if "%1" == "" (
    @echo Usage: 
    @echo.
    @echo   which 'cmd'
    @echo.
    @echo.if 'cmd' is not found, ERRORLEVEL is set to 1
    @echo.  
) 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) 
)
link|improve this answer
1  
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
feedback

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.

link|improve this answer
feedback

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

link|improve this answer
feedback

You can try searching for the command using the following:

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

link|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
1  
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
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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