2013-02-18 33 views
0

在PowerShell腳本中,我需要啓動該進程PowerShell和告訴它運行腳本foo.ps1像這樣:嵌套PowerShell的參數

start-process powershell C:\foodir\foo.ps1 

但是我遇到了問題,當我需要的foo腳本是運行參數。我試着像這樣的代碼:

start-process powershell (C:\foodir\foo.ps1 -paramforfoo test) 

但這只是凍結腳本當它到達此行,不引發錯誤。我認爲它試圖將參數測試傳遞給powershell進程,而不是腳本foo。我怎樣才能用參數運行這個腳本?

+1

http://stackoverflow.com/questions/651223/powershell-start-process-and-cmdline-switches – Microfed 2013-02-18 18:45:25

回答

0

嘗試使用引號來收集您的命令。例如。

Start-Process powershell ".\Untitled3.ps1 -testparam 'hello world'" 
+0

非常感謝。很棒。 – bob0007 2013-02-18 19:28:56