Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Linux, we have the "which" command to find out the path of an executable.
What is its Windows equivalent? Is there any PowerShell command for doing that?

share|improve this question

migrated from Nov 6 '10 at 0:38

This question came from our site for professional and enthusiast programmers.

Some versions of Windows (I think Windows 2003 and up) have the where command:

c:\>where ping
share|improve this answer
where work for me in Windows 7 – Nam G VU Oct 10 '11 at 16:30
This only works in cmd, not in PowerShell (in my experience) – Thomas Oct 13 '14 at 15:15
where /r c:\ fileName adding the /r c:\ allowed me to perform a recursive search starting at the root of the C drive using Windows 7 Professional it seems to not be in… – CrandellWS Sep 25 '15 at 9:09

Yes, Get-Command will find all commands including executables:

PS\> Get-Command ipconfig

If you want to limit the commands to just executables:

PS\> Get-Command -CommandType Application

Will find all exes in your path. There is an alias for interactive use:

PS\> gcm net* -CommandType Application

To get the path of an executable, you can use the Path property of the returned object. For example:

PS\> (Get-Command notepad.exe).Path

For more info, run man Get-Command -full.

share|improve this answer

In addition to user10404, the help command will work on aliases, so you can use the same command name (gcm) for help and interactive use:

help gcm -Parameter *
# or
man gcm -Par *
share|improve this answer

You must log in to answer this question.