Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

migrated from stackoverflow.com Nov 6 '10 at 0:38

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

3 Answers

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

c:\>where ping
C:\Windows\System32\PING.EXE
share|improve this answer
2  
where work for me in Windows 7 –  Nam G. VU Oct 10 '11 at 16:30
add comment

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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.