Windows中查找命令的路径 (类似Linux中的which命令)
Various.
whereis a direct equivalent:C:\Users\Joey>where cmd C:\Windows\System32\cmd.exeNote that in PowerShell
whereitself is an alias forWhere-Object, thus you need to usewhere.exein PowerShell.In
cmdyou can also usefor:C:\Users\Joey>for %x in (powershell.exe) do @echo %~$PATH:x C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exeIn PowerShell you have
Get-Commandand its aliasgcmwhich does the same if you pass an argument (but also works for aliases, cmdlets and functions in PowerShell):PS C:\Users\Joey> Get-Command where CommandType Name Definition ----------- ---- ---------- Alias where Where-Object Application where.exe C:\Windows\system32\where.exeThe first returned command is the one that would be executed.