【问题标题】:Powershell: run msiexec with dynamically created parametersPowershell:使用动态创建的参数运行 msiexec
【发布时间】:2012-01-18 12:32:26
【问题描述】:

在我的 powershell 脚本中,我需要运行 msiexec 并传递一些参数来初始化它。问题是,如果参数包含空格字符“”,powershell 不会正确执行 msiexec。例如命令:

msiexec /i .\Setup.msi ConnectionString="Initial Catalog=something;Integrated Security=True;Pooling=False"

参数 ConnectionString 包含空格,这会导致 msiexec 没有正确执行,我得到 msiexec 错误代码 1639 - Invalid command line argument。如果我从连接字符串中删除空格,则 msiexec 将正确执行。

有人知道如何解决吗?

【问题讨论】:

  • 你可以试试这个:msiexec /i .\Setup.msi 'ConnectionString="Initial Catalog=something;Integrated Security=True;Pooling=False"'
  • 我试了一下,不幸的是,它不起作用,但谢谢你的想法。

标签: scripting powershell windows-installer


【解决方案1】:

这样试试:

Start-Process -FilePath msiexec -ArgumentList / /i, .\Setup.msi, "ConnectionString='Initial Catalog=something;Integrated Security=True;Pooling=False'"  -Wait 

【讨论】:

    【解决方案2】:

    尝试像这样单引号:

    & msiexec.exe /i .\Setup.msi ConnectionString='"Initial Catalog=something;Integrated Security=True;Pooling=False"'
    

    【讨论】:

      猜你喜欢
      • 2019-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-06
      • 1970-01-01
      • 2018-10-29
      • 2020-11-11
      相关资源
      最近更新 更多