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?
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.
If you want to make it short, create a one line which.cmd file with the content
This will search the first parameter (%1) fed to the script and display the full path of found file. Good place to put this script in windows 10 is %LOCALAPPDATA%\Microsoft\WindowsApps\which.cmd
And you get your which command in path.
c:\>which cmd.exe c:\>echo C:\Windows\System32\cmd.exe C:\Windows\System32\cmd.exe