Is there an equivalent of 'which' on the Windows command line?

后端 未结 26 2523
悲哀的现实
悲哀的现实 2020-11-22 00:40

As I sometimes have path problems, where one of my own cmd scripts is hidden (shadowed) by another program (earlier on the path), I would like to be able to find the full pa

26条回答
  •  误落风尘
    2020-11-22 00:53

    In PowerShell, it is gcm, which gives formatted information about other commands. If you want to retrieve only path to executable, use .Source.

    For instance: gcm git or (gcm git).Source

    Tidbits:

    • Available for Windows XP.
    • Available since PowerShell 1.0.
    • gcm is an alias of Get-Command cmdlet.
    • Without any parameters, it lists down all the available commands offered by the host shell.
    • You can create a custom alias with Set-Alias which gcm and use it like: (which git).Source.
    • Official docs: https://technet.microsoft.com/en-us/library/ee176842.aspx

提交回复
热议问题