Home » Questions » Computers [ Ask a new question ]

How do I find the location of an executable in Windows?

How do I find the location of an executable in Windows?

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

Asked by: Guest | Views: 68
Total answers/comments: 4
Guest [Entry]

"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."
Guest [Entry]

"open Powershell and use gcm command
gcm [your_exe]
demo

Source: Get-Command"
"open Powershell and use gcm command
gcm [your_exe]
demo

Source: Get-Command"
Guest [Entry]

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).
Guest [Entry]

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