2016-02-04 31 views
0

如果我創建計劃任務時啓動的PowerShell腳本是這樣的:指定路徑的腳本放慢參數在計劃任務

Powershell -command "& 'C:\test.ps1'" 

我如何可以把一個路徑參數中的一個參數不中斷-command參數?

Powershell -command "& 'C:\test.ps1 -path C:\Program Files(x86)\test'" 

是行不通的,因爲它找不到"C:\Program"

Powershell -command "& 'C:\test.ps1 -path 'C:\Program Files(x86)\test''" 
or 
Powershell -command "& 'C:\test.ps1 -path "C:\Program Files(x86)\test"'" 

是行不通的,因爲包裹路徑引號會中斷-command參數

+1

你應該指定'-file'而不是'-command' – Avshalom

+0

@Avshalom'-file「C:\ script.ps1 -path'C:\ test'」'這樣嗎? – SimonS

回答

1

使用-File參數,而不是-Command

Powershell -File C:\script.ps1 -path C:\test 
+0

非常感謝 – SimonS

相關問題