Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I remembered that I used a tool called as where to find locations for any executable programs like this in a console:

 C:\Tmp\Where myTool.exe
 C:\Program Files\MyApp\myTools.exe
 ....

Now I cannot find this tool. Not sure if Windows has a build-in tool to do that search?

share|improve this question
    
Various answers over on Is there an equivalent of 'which' on windows? - Stack Overflow –  Satanicpuppy Sep 30 '09 at 17:17
    
IF the application is running & you need to know its location, use Process Explorer( from Sys Internals). –  Ganesh R. Sep 30 '09 at 17:19
add comment

9 Answers

up vote 4 down vote accepted

I think you may be thinking of the which command in Linux.

$ which bash
/bin/bash

I'm not aware of an equivalent tool in Windows.

EDIT: I just remembered that there's a package called Unix Utils for Windows that would provide this functionality for you.

share|improve this answer
    
github.com/bmatzelle/gow/wiki is a descendant of Unix Utils that is more convenient to use, called Gnu on Windows. It has more utilities and an installer. –  Simon D Jul 25 '12 at 6:38
3  
Dammit I can't downvote. The OP was right and there is a "where.exe". See the answer below here: superuser.com/a/440904/59929 –  Piers Karsenbarg Sep 3 '12 at 10:17
    
Using *nix makes you think slowly and ineffective, and unable to understand OPs' questions. –  Nakilon Aug 26 '13 at 12:31
add comment

According to the StackOverflow answer at Is there an equivalent of 'which' on windows?, where.exe does this on Windows 7 and Windows Server 2003 and later:

Example

C:\> where ping

Output:

C:\Windows\System32\PING.EXE
share|improve this answer
add comment

use dir:

cd \
dir /s /b mytool.exe

the cd \ part changes you to the root of the drive, to ensure searching starts at the top of the hierarchy.

share|improve this answer
    
It seems like doing a command line Windows Search. –  Ganesh R. Sep 30 '09 at 17:18
2  
That does a recursive search of the drive and would take forever. –  djhowell Sep 30 '09 at 17:19
2  
The only way to find executables that AREN'T in the PATH environment variable is to do this. He never specified his path, he said any executable. –  John T Sep 30 '09 at 17:31
    
it does find the executable but takes a while. –  Michael Z Sep 2 '12 at 22:43
add comment

Frustrating that it's not built-in as a simple command.

However, there are several solutions, one of which is a batch file.

Create a batch file (which.bat) as follows:

@setlocal
@set P2=.;%PATH%
@for %%e in (%PATHEXT%) do @for %%i in (%~n1%%e) do @if NOT "%%~$P2:i"=="" echo %%~$P2:i

This looks in the local directory, will take a filename parameter with or without an extension, and return the first match from the current directory or in the PATH.

Then run it like which cmd.exe to find the cmd.exe that will execute if you type in cmd.

share|improve this answer
add comment

EDIT: I should have added, if you can't use the WHERE command from the command prompt, check your PATH variable. (Just use the "path" command.) Make sure C:\Windows\System32 is in your path. That's where "where.exe" is located.

WHERE is the command you're looking for! WHERE is like a cross between the UNIX shell built-in "which" and the "locate" command, in that it works for both command executables and regular files.

It's also somewhat more complex than either of those two, although, in general a simple

WHERE <file>

will work.

It's different from the "locate" command in that it's not looking through the entire filesystem. Instead, the default behavior is to look for files in two locations:

  • The current directory.
  • All of the directories in the PATH variable.

So, any command that you can run directly from a command prompt without specifying the directory, will be found by the WHERE command. (Because any command like that is already in the PATH variable list.)

If you want to search only in the command path variable, you can use:

WHERE "$path:<search text>"

If, on the other hand, you want to find all copies of a file in a directory tree, you can use:

WHERE /R <Top Level Directory> <search text>

Finally, WHERE will find commands and any files with an extension from the PATHEXT variable without including the extension. All other files have to be specified either exactly or with wildcards.

Take for example the files "dxdiag.exe" and "dxdiagn.dll"

WHERE /R C:\Windows dxdiag

succeeds in returning all versions of "dxdiag.exe" because ".exe" is one of the extensions in the PATHEXT variable. (Note: "WHERE dxdiag" would have worked as well, because C:\Windows\System32 is in the PATH variable.)

WHERE /R C:\Windows dxdiagn

one the other hand, fails to return a result, because ".dll" is not in PATHEXT.

In this case, using:

WHERE /R C:\Windows dxdiagn*

successfully returns all versions of dxdiagn.dll.

For more information, use "WHERE /?". Hope this helps!

share|improve this answer
add comment

If you just want which, the GnuWin32 project has a bunch of unix utils with individual installers.

share|improve this answer
add comment

On windows you can use the free utility Everything search engine to search instantly for any file by full or partial name (if your hard disk is formatted in ntfs).

share|improve this answer
add comment

Note that some things might be a little different for PowerShell:

PS C:\Users\Rob.wb-devel> where ping

PS C:\Users\Rob.wb-devel> where git

PS C:\Users\Rob.wb-devel> whereis.bat git
C:\Program Files (x86)\Git\cmd\git.exe

PS C:\Users\Rob.wb-devel> where.exe git
C:\Program Files (x86)\Git\cmd\git.exe
share|improve this answer
add comment

If you just need the path to launch it, it's often better to use the start command. For example, you can use "start chrome.exe" to start Chrom{e|ium}, regardless of where it is installed.

share|improve this answer
add comment

Your Answer

 
discard

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.