我想了解 CMD shell 使用哪个版本的可执行文件。在任何 Unix shell 中,我都会使用 which
找到它。
Windows shell 中是否有等效的命令?
最佳答案
各种。
其中
是直接等效项:C:\Users\Joey>where cmd C:\Windows\System32\cmd.exe
请注意,在 PowerShell 中
where
本身是Where-Object
的别名,因此您需要在 PowerShell 中使用where.exe
。在
cmd
中,您还可以使用for
:C:\Users\Joey>for %x in (powershell.exe) do @echo %~$PATH:x C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
在 PowerShell 中,您有
Get-Command
及其别名gcm
,如果您传递参数,它会执行相同的操作(但也适用于别名、cmdlet 和函数)在 PowerShell 中):PS C:\Users\Joey> Get-Command where CommandType Name Definition ----------- ---- ---------- Alias where Where-Object Application where.exe C:\Windows\system32\where.exe
第一个返回的命令是要执行的命令。
关于powershell - bash 上相当于 `which` 的 cmd/powershell 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11009598/