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?


14 Answers 14


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


C:\> where ping



In PowerShell use where.exe, Get-Command (or its abbreviation gcm), as where is the default alias for Where-Object.

  • 30
    This should be makred as the correct answer as it works without installing extra software
    – Cookie
    Oct 17, 2014 at 12:28
  • 66
    An important part of this answer is that in powershell, where is a default alias for the Where-Object, so you instead need to use where.exe, or gcm/Get-Command Nov 13, 2017 at 18:03
  • 2
    What about powershell. How can I achieve the same in powershell?
    – krv
    Sep 15, 2018 at 14:12
  • 7
    @krv As @DaveAndersen mentioned, in powershell you can type Get-Command ping (or just gcm ping), which will give you full path, along with some other info.
    – Sam
    Jan 9, 2019 at 9:25
  • 3
    @stevec please read the above comment: in PowerShell you must use where.exe instead of where
    – phuclv
    Mar 30, 2020 at 2:11

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". Note the following command and its output:

WHERE /R C:\Windows dxdiag


It 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

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

In this case, look at the result that adding a wildcard gives us:

WHERE /R C:\Windows dxdiagn*


It successfully returns all versions of dxdiagn.dll.

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

  • 5
    where where C:\Windows\System32\where.exe :)
    – vp_arth
    Dec 6, 2016 at 15:13
  • 1
    @vp_arth Was just thinking exactly the same thing :) May 31, 2019 at 13:54

For me, what worked was

Get-Command chromedriver

which returns something like

CommandType     Name                       Version    Source
-----------     ----                       -------    ------
Application     chromedriver.exe     C:\WINDOWS\chromedriver.exe

Simply replace chromedriver with the program you're looking for

  • good job ! where doesnt work for mthis, this works!
    – Siwei
    Jan 29 at 7:03
  • 1
    And "Get-Command -ShowCommandInfo" makes sure you can read the full path. Feb 6 at 14:37

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
  • Thanks, this works for both cmd and PowerShell Jan 17, 2019 at 12:12
  • 1
    "whereis" whereis.bat ???;)
    – Timo
    Mar 20, 2020 at 13:51
  • For Powershell as an addition please see my comment on @john t answer.
    – Timo
    Mar 20, 2020 at 13:52

open Powershell and use gcm command

gcm [your_exe]


enter image description here

Source: Get-Command


You can also use Select-Object alias: select to filter that field you are interested in.

for example:

gcm git.exe | select Source

enter image description here

  • Works great, thanks! Mar 2, 2021 at 11:54
  • Can't believe I had to scroll so low to finally find a working command. The only one that can tell me where is gdb located. Thanks May 15, 2022 at 9:15

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.

  • It seems like doing a command line Windows Search.
    – Ganesh R.
    Sep 30, 2009 at 17:18
  • 8
    That does a recursive search of the drive and would take forever.
    – djhowell
    Sep 30, 2009 at 17:19
  • 9
    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, 2009 at 17:31
  • it does find the executable but takes a while.
    – Michael Z
    Sep 2, 2012 at 22:43
  • 1
    this of course only works if you know the name of the executable or at least a portion of the name Nov 17, 2016 at 9:04

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).

  • 1
    Night and day difference between this and windows search.
    – AnthonyVO
    Dec 15, 2016 at 15:42

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:

@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.


If you're using Powershell, where is something totally different than cmd's where.

In powershell, type:

(Get-Command powershell.exe).Path
  • Cheers. Didn't notice the typo.
    – Donal
    Apr 29, 2020 at 13:24

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


In PowerShell

(@($env:path.split(";")) + (pwd).Path)  | where { dir $_ -ErrorAction SilentlyContinue |? Name -eq foo.exe }

You can easily convert this into a Cmdlet.

Another way to accomplish this, as suggested in an edit:

get-command notepad.exe | select Source

Heh, I just have to post this Windows' one liner batch file:

C:>type wh.cmd
@for %%f in (%*) do for %%e in (%PATHEXT% .dll .lnk) do for %%b in (%%f%%e) do for %%d in (%PATH%) do if exist %%d\%%b echo %%d\%%b

A test:

C:>wh ssh

Not quite a one-liner if you wrap the code in setlocal enableextensions and endlocal, which are required for users who don't have the extensions enabled by default.


WHERE is great, but slow. I found querying registry to be faster, but less reliable so I combined the two ideas into a function like so:



FOR /F "skip=2 tokens=1,2* USEBACKQ" %%N IN (`reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\%~1" /t REG_SZ  /v "Path"`) DO (
 IF /I "%%N" == "Path" (
  SET wherepath=%%P%~1
  GoTo Found

FOR /F "tokens=* USEBACKQ" %%F IN (`where.exe %~1`) DO (
 SET wherepath=%%F
 GoTo Found

FOR /F "tokens=* USEBACKQ" %%F IN (`where.exe /R "%PROGRAMFILES%" %~1`) DO (
 SET wherepath=%%F
 GoTo Found

FOR /F "tokens=* USEBACKQ" %%F IN (`where.exe /R "%PROGRAMFILES(x86)%" %~1`) DO (
 SET wherepath=%%F
 GoTo Found

FOR /F "tokens=* USEBACKQ" %%F IN (`where.exe /R "%WINDIR%" %~1`) DO (
 SET wherepath=%%F
 GoTo Found

SET %2=%wherepath%



CALL "app_path_func.cmd" WINWORD.EXE PROGPATH



C:\Program Files (x86)\Microsoft Office\Office15\WINWORD.EXE
Press any key to continue . . .



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.

You must log in to answer this question.

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