2016-02-04 27 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

相关问题