如果msiexec的命令行参数包含空格,则会在Powershell上中断 [英] Command line arguments for msiexec break on powershell if they contain space
问题描述
我正在尝试在installshield安装程序中设置一个公共属性,其值包含空格。运行MSI安装程序时,我在PowerShell命令提示符下使用以下命令。由于该值包含空格,因此我使用双引号将其传递
I'm trying to set a public property in an installshield installer with a value containing space. While running the MSI installer I'm using below command on PowerShell command prompt. Since the value contains spaces so I used double quotes to pass the value
msiexec -i "myinstaller.msi" MYDIRPATH="C:\new folder\data.txt"
它将参数作为<$中断命令c $ c> C:\new folder\data.txt 在字符串 new folder
中有一个空格,并导致以下错误提示msiexec暗示了传递给msiexec命令的参数存在问题:
It breaks the command as the argument value C:\new folder\data.txt
has a space in the string new folder
and results in below error prompt of msiexec which is suggestive of the fact that arguments passed to the msiexec command is problematic:
如果我在Windows默认命令外壳提示符下运行相同的命令,那么它就像一个超级按钮。
If I run the very same command on windows default command shell prompt then it works like a charm.
我尝试过的选项:
- 使用单引号代替双引号
- 使用反斜杠(`)字符根据这个答案。
- Using single quote in place of double quotes
- Using a back tick (`) character before space in the argument as per this answer.
推荐答案
尝试一下
msiexec -i "myinstaller.msi" MYDIRPATH=`"C:\new folder\data.txt`"
PowerShell中的转义字符是grave-accent(`)。
The escape character in PowerShell is the grave-accent(`).
这篇关于如果msiexec的命令行参数包含空格,则会在Powershell上中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!