【发布时间】:2025-12-26 01:55:11
【问题描述】:
在我的powershell 脚本中,我需要安静地运行几个msiexec 命令。问题是当我尝试运行命令时,Windows Installer 帮助弹出窗口显示而不是执行命令。 (下图)
相同的命令在 cmd 中运行良好。下面是我的命令。我将命令中的& 保留在双引号中,以将其视为建议的字符串。
& msiexec /log c:\msxml.log /quiet /I "&" D:\LoadGeneratorsetup\prerequisites\msxml6\msxml6_x64.msi
我尝试使用Start-Process -FilePath 运行它,但最终出现以下错误。
Start-Process : A positional parameter cannot be found that accepts argument 'c:\msxml.log'.
At line:1 char:1
+ Start-Process -FilePath msiexec /log c:\msxml.log /quiet /I "&" D:\Lo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand
有人可以提供有关如何使用 powershell 安静地执行命令的详细信息。
【问题讨论】:
-
只需去掉开头的“&”和 & 所以 :: msiexec /log c:\msxml.log /quiet /ID:\LoadGeneratorsetup\prerequisites\msxml6\msxml6_x64.msi
-
谢谢欧文。它在删除 & 后工作。但是最后一个
msiexec仍在弹出Windows Installer 弹出窗口。该命令如下所示 -& msiexec /i "& D:\LoadGeneratorsetup\HP_LoadGenerator.msi" /qb /l*vx "& D:\LoadGeneratorsetup\Logs\InstallationLogs"+"_"+(Get-Date -Format "yyyy-MM-dd-hh-mm-s")+".txt"我尝试删除所有 & 但仍然相同。你能帮帮我吗? -
检查我的答案
-
请在下面查看我的答案以获取指向the Windows Installer PowerShell Module的一些链接。
标签: powershell scripting windows-installer