【发布时间】:2021-02-23 16:42:25
【问题描述】:
我正在尝试从 installshield 设置文件中传递参数,我做错了什么?
$STExecute = "C:\Files\setup.exe"
$STArgument = '/s /f2"c:\windows\setuplogs\inst.log"'
Start-Process Powershell.exe -Credential "Domain\userTempAdmin" `
-ArgumentList "-noprofile -command &{Start-Process $($STExecute) $($STArgument) -verb runas}"
我得到了打击错误,你可以看到它删除了双引号,这需要在那里,我什至无法让它在第二个启动过程中传递 /s 参数:
Start-Process : A positional parameter cannot be found that accepts argument '/f2c:\windows\setuplogs\dmap110_inst.log'
【问题讨论】:
-
Start-Process 只接受一个参数,如果要向启动进程传递更多参数,则需要使用-ArgumentList
-
谢谢,但双引号仍然被删除
-
顺便说一句:请注意,在
& { ... }中包装传递给PowerShell CLI 的-command/-c参数的命令是不必要的。
标签: powershell arguments start-process