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 comm
To complement Marko Tica's helpful answer:
Calling external utilities in PowerShell is notoriously difficult, because PowerShell, after having done its own parsing first, rebuilds the command line that is actually invoked behind the scenes, and it's far from obvious what rules are applied.
To help with this problem, PSv3+ offers --%, the stop-parsing symbol, which is the perfect fit here, given that the command line contains no references to PowerShell variables or subexpressions: It passes the rest of the command line as-is to the external utility, save for potential expansion of %...%
-style environment variables:
# Everything after --% is passed as-is.
msiexec --% -i "myinstaller.msi" MYDIRPATH="C:\new folder\data.txt"
As for what actually happened in your original attempt:
PowerShell translated
MYDIRPATH="C:\new folder\data.txt"
into
"MYDIRPATH=C:\new folder\data.txt"
behind the scenes - note how the entire token is now enclosed in "..."
.
Arguably, these two forms should be considered equivalent by msiexec
, but all bets are off in the anarchic world of Windows command-line argument parsing.