Windows中查找命令的路径 (类似Linux中的which命令)
Posted sforiz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows中查找命令的路径 (类似Linux中的which命令)相关的知识,希望对你有一定的参考价值。
where
is a direct equivalent:C:\\Users\\Joey>where cmd C:\\Windows\\System32\\cmd.exe
Note that in PowerShell
where
itself is an alias forWhere-Object
, thus you need to usewhere.exe
in PowerShell.In
cmd
you can also usefor
:C:\\Users\\Joey>for %x in (powershell.exe) do @echo %~$PATH:x C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe
In PowerShell you have
Get-Command
and its aliasgcm
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 where CommandType Name Definition ----------- ---- ---------- Alias where Where-Object Application where.exe C:\\Windows\\system32\\where.exe
The first returned command is the one that would be executed.
以上是关于Windows中查找命令的路径 (类似Linux中的which命令)的主要内容,如果未能解决你的问题,请参考以下文章