2015-11-29 221 views
1

我試圖從PowerShell的3 ISE運行這個命令:運行可執行文件的語法?

&"C:\inetpub\htpasswd.exe -bc C:\inetpub\wwwroot\xyz\password\passMD5.txt sm88555 sm88999" 

,但得到這個錯誤:

is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

我覺得PowerShell中停止第一空間之後正確評估呢?

+0

IEX - 調用-表達[-Command] [] – lloyd

回答

2

iex - Invoke-Expression時&失敗

$htPassword = "C:\inetpub\htpasswd.exe" 
$htParams = "C:\inetpub\wwwroot\xyz\password\passMD5.txt sm88555 sm88999" 
Invoke-Expression -Command "$htPassword $htParams" 

myeval由Joel-B-FANT

2

呼叫運營商不解釋整個COMMANDLINES /表達式可以處理得很好我使用。這就是Invoke-Expression的用途。從命令中分離的參數(並且彼此),如果你想使用的呼叫操作:

& "C:\inetpub\htpasswd.exe" -bc "C:\inetpub\wwwroot\xyz\password\passMD5.txt" "sm88555" "sm88999"