windows中查找某个命令的路径(类似于linux中的which)

来源:互联网 发布:xbox one 手柄驱动mac 编辑:程序博客网 时间:2024/05/16 06:35

本篇文章转载自:http://www.open-open.com/home/space-4097-do-blog-id-11710.html


Various.

  1. where is a direct equivalent:

    C:\Users\Joey>where cmdC:\Windows\System32\cmd.exe

    Note that in PowerShell where itself is an alias for Where-Object, thus you need to usewhere.exe in PowerShell.

  2. In cmd you can also use for:

    C:\Users\Joey>for %x in (powershell.exe) do @echo %~$PATH:xC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  3. In PowerShell you have Get-Command and its alias gcm which does the same if you pass an argument (but also works for aliases, cmdlets and functions in PowerShell):

    PS C:\Users\Joey> Get-Command whereCommandType     Name          Definition-----------     ----          ----------Alias           where         Where-ObjectApplication     where.exe     C:\Windows\system32\where.exe

    The first returned command is the one that would be executed.


0 0