Windows / Powershell Unix version of Utility

The "which" utility, when launched with the parameter that named the executable file, will tell you the first executable file with the name that it will find in your path, if it is found at all. This gives a good idea of ​​which version of the executable file will be running. (Forgive me if this description is incomplete, but it conveys the general idea)

I’m looking for either the “what” utility port, or the Powershell command, or some other utility that I don’t know about, does the same.

I reviewed the following SO question (and try the logic of the for loop in the selected answer). I would rather have one team that implements this functionality and wants to see if it exists. If something like this does not exist, this logic can be pretty easily inserted into the script:

unix "which java" is the equivalent command in windows?


A "winwhich" utility for CodeProject exists. It did not update after 6 years or so, and when it was built on my Win 7 machine with VS 2010, it crashed at startup. I plan to do my due diligence to find out why she crashed, but we don’t have time until tonight.


Has anyone used another utility or command on Windows to emulate this feature?

+4
source share
3 answers

You can use Get-Command <command> or shorten it to gcm .

+11
source

where does the same in recent versions of Windows. If you run the PowerShell command, Novakov’s answer is correct.

+6
source

On Windows from the command line (cmd)

 cmd> where <command> 

In Powershell (PS)

 ps> get-command <command> ps> where.exe <command> 

You can also add an alias to the "which" command in PS

 ps> New-Alias which get-command 

and now you can use the "which" command as usual

 ps> which <command> 
+1
source

Source: https://habr.com/ru/post/1387086/


All Articles