Windows中查找命令的路徑 (類似Linux中的which命令)
Various.
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.
本文由用戶 灬猜想灬 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!