Say I have a program X.EXE
installed in folder c:\abcd\happy\
on the system. The folder is on the system path. Now suppose there is another program on the system that's also called X.EXE but is installed in folder c:\windows\
.
Is it possible to quickly find out from the command line that if I type in X.EXE
which of the two X.EXE
's will get launched? (but without having to dir search or look at the process details in Task Manager).
Maybe some sort of in-built command, or some program out there that can do something like this? :
detect_program_path X.EXE
Use the
where
command. The first result in the list is the one that will execute.According to this blog post,
where.exe
is included with Windows Server 2003 and later, so this should just work with Vista, Win 7, et al.On Linux, the equivalent is the
which
command, e.g.which ssh
.Here's a little cmd script you can copy-n-paste into a file named something like
where.cmd
:As the thread mentioned in the comment,
get-command
in powershell can also work it out. For example, you can typeget-command npm
and the output is as below: