Powershell:使用动态创建的参数运行 msiexec [英] Powershell: run msiexec with dynamically created parameters

查看:29
本文介绍了Powershell:使用动态创建的参数运行 msiexec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

in my powershell script, I need to run msiexec and pass few parameters to initialize it. The problem is, that if a parameter contains space character " ", powershell doesn't execute msiexec correctly. For example the command:

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

参数 ConnectionString 包含空格,这会导致 msiexec 未正确执行,我收到 msiexec 错误代码 1639 - 无效的命令行参数.如果我从连接字符串中删除空格,则 msiexec 会正确执行.

The parameter ConnectionString contains spaces, and this causes that msiexec is not executed correctly, I get msiexec error code 1639 - Invalid command line argument. If I remove spaces from from connection string, msiexec is executed correctly.

有人知道如何解决吗?

推荐答案

试试这个方法:

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

这篇关于Powershell:使用动态创建的参数运行 msiexec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆