powershellcommand-line-argumentsinstallshieldwindows-installer

Command line arguments for msiexec break on PowerShell if they contain space


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 prompt. Since the value contains a space so I used double quotes to pass the value

msiexec -i "myinstaller.msi" MYDIRPATH="C:\new folder\data.txt"

It breaks the command as the argument value C:\new folder\data.txt has a space in the string new folder. It results in showing up below error prompt of msiexec:

enter image description here

It suggests that arguments passed to the msiexec command has some problem.

But if I execute the same command on Windows default command prompt then it runs fine:

enter image description here

Few other options that I've tried to make things work on PowerShell prompt are as below:

  1. Using single quote in place of double quotes
  2. Using a back tick (`) character before space in the argument as per this answer.

Solution

  • Try with this

    msiexec -i "myinstaller.msi" MYDIRPATH=`"C:\new folder\data.txt`"
    

    The escape character in PowerShell is the grave-accent(`).