I had to deal with an issue at work lately that was driving me nuts for a while, but I finally found a solution. If you’re having a similar problem, maybe this post can help you. My problem had to do with passing command line parameters to our installer when the parameters have spaces in them, such as when they’re paths to a location on disk. The short answer is that if you need to pass a double quote (“) in a parameter, escape it with another double-quote. However, I can’t stop here, or this would be a very short post.
I’ve been working on the installer for my company’s product and making certain improvements to it. Our installer is built using InstallAware. By default, InstallAware produces a .exe installer instead of a .msi installer because their technology provides certain enhancements over a basic msi such as stronger compression. Running this installer .exe from a command line is easy, and parameters can be passed like so:
setup.exe PARAM1="value 1" PARAM2="value 2"
So far, so good. The problem is that this installer can not be run through group policy on Windows Server, a technology that makes it easy for an admin to install the software on many computers remotely. Group policy can only run .msi installers in this manner. InstallAware includes a group policy wizard that will wrap your .exe in a .msi specifically for this purpose, which is great. The complication comes from passing those command line parameters. The msi generated by the group policy wizard can take a parameter CMDLINE which it will then pass along to the .exe inside, like so:
setup.msi CMDLINE="PARAM1=value1 PARAM2=value2"
We can see that double-quotes are needed to enclose the value of CMDLINE if there are multiple parameters. The .exe will then be extracted from the msi and executed:
setup.exe PARAM1=value1 PARAM2=value2
But what happens if value1 or value2 themselves contain a space? This is where we run into complications.
The answer, as I’ve written at the top of this post is that we can escape a double-quote with another double-quote, like so:
setup.msi CMDLINE="PARAM1=""value 1"" PARAM2=""value 2"""
Notice the double-quotes around value 1 and value 2, with a third double-quote at the end. It’s awkward and unwieldy, but that’s the way it has to be done in this case.
At the very least, clients need to be told about this and how to properly format the command line.





No comments yet
Comments feed for this article