2013-05-27 106 views

回答

8

以下爲我工作:

PS C:\Users\Bill> where.exe calc 
C:\Windows\System32\calc.exe 

當您在PS鍵入where,它不等同於執行where.exe

PS C:\Users\Bill> where <press ENTER> 

cmdlet Where-Object at command pipeline position 1 
Supply values for the following parameters: 
Property: 

所以,當你鍵入where calc正在執行Where-Object calc(別名的Where-Objectwhere?),因此不返回任何內容,也不執行where.exe calc

您可以使用Get-Command(別名爲gcm)cmdlet替代where.exe。以下是使Get-Command功能與where.exe完全相同的示例功能。如果您將其放在您的PowerShell profile中,它將始終在您的會話中可用。

function which ($command) { 
    Get-Command -Name $command -ErrorAction SilentlyContinue | 
     Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue 
} 

以下鏈接可能是有用的 -

Equivalent of *Nix 'which' command in Powershell?

https://superuser.com/questions/34492/powershell-equivalent-to-unix-which-command

希望這有助於。

+0

感謝您的提示。這並不能解釋爲什麼'哪裏'在PS中不顯示任何輸出。 – Ragesh

+0

@Ragesh我更新瞭解釋的答案和一種方法來解決這個問題。如果你有問題,請告訴我。 – Bill

+2

您也可以使用cmd.exe運行它。像'cmd/c「calc'' –

相關問題