Powershell: run msiexec with dynamically created parameters

走远了吗. 提交于 2019-12-13 01:44:06

问题


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"

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.

Do anybody have an idea how to solve it?


回答1:


Try in this way:

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



回答2:


Try single quoting it like this:

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


来源:https://stackoverflow.com/questions/8910146/powershell-run-msiexec-with-dynamically-created-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!