-1

有人可以解释为什么这样做:

$cred = Get-Credential
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"C:\temp\jre1.7.0_17.msi`"" -Credential $cred -wait

但这不是:

$cred = Get-Credential
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"C:\temp\jre1.7.0_17.msi`" ""`/qn REBOOT=ReallySuppress JAVAUPDATE=0 WEBSTARTICON=0 SYSTRAY=0`" ""/log c:\temp\javainst.log" -Credential $cred -wait
4

1 回答 1

0

我要担心的第一件事是您逃避每个特殊字符的方式。如果做得好,它会正常工作,但在这里似乎没有必要。如果您需要在字符串中包含双引号,则将参数包含在单引号中。

您可以尝试以下方法,看看是否有帮助?

$cred = Get-Credential
Start-Process -FilePath "msiexec.exe" -ArgumentList '/i "C:\temp\jre1.7.0_17.msi" /qn REBOOT=ReallySuppress JAVAUPDATE=0 WEBSTARTICON=0 SYSTRAY=0 /log c:\temp\javainst.log' -Credential $cred -wait

另外,正如我在你之前非常相似的帖子中评论的那样,你能解释一下为什么你需要使用msiexec而不是 java 自己的 exe 设置吗?

编辑试试这个:

$cred = Get-Credential
Start-Process -FilePath "c:\temp\jre-7u17-windows-i586.exe" -ArgumentList '/S /L c:\temp\javainst.log REBOOT=ReallySuppress JAVAUPDATE=0 WEBSTARTICON=0 SYSTRAY=0' -Credential $cred -wait
于 2013-03-13T18:14:25.117 回答