Windows – Is it possible to detect file location when running it?

command linewindowswindows 7

Say I have a file called calc.exe ( for example).

When I go to CMD and I run calc.exe it runs because Windows has PATH settings in its environment variables.

Path information is also accessible via typing path in cmd. ( as we all know).

Question

But – Is there any command in cmd that shows me information like this :

c:\> locate_Where_It_Will_run_From calc.exe

Response :

c:\windows

I mean , the only solution which I see now is to run :

dir /s  calc.exe

And then to match results with the PATH information .

Is there any such command which will show me the information of my example above ?

Best Answer

On recent Windows systems, the command is where:

> where calc
c:\windows\system32\calc.exe

> where where
c:\windows\system32\where.exe

PowerShell has Get-Command for the same purpose.

Note that where only covers %PATH%, but launching apps via "Run…" via Start menu additionally uses App Paths from the Registry.


The Unix equivalents are which (-a) and type (-a) (the latter also includes shell-builtins).