Basic MSI Project: Setup.exe Custom Command-Line Arguments
Posted by Chad | Posted in InstallShield | Posted on 11-02-2010
0
This one eluded me for way too long considering how straight-forward it is. So, in an effort to help others who may have the same question, I thought I’d write it down..
Problem: For a Basic MSI Project in InstallShield 2009, I need to pass in 1 or more custom command-line arguments to use during installation/un-installation/etc.
Step 1 – Accessing your custom command-line arguments
First, accessing these values are as easy as accessing other variables in InstallShield. All you need to do is use the format [MYARGUMENTNAME]. So, for example, if you want to use one of the arguments when invoking an executable from a custom action, it may look like this image below. My custom action is invoking an executable called myapp.exe and I am accessing a custom command line argument named FILENAME to use as part of the invocation of my executable.
Step 2 – Passing in your custom command-line arguments
It’s really this simple.. each argument needs to be preceeded by a /v and wrapped in quotes. Continuing the example above, here is how I pass in my custom command line argument named FILENAME:
setup.exe /v"FILENAME=\"myfile.txt\""
This would result in my custom action invoking my executable as follows: myapp.exe -f myfile.txt
To be clear on multiple custom command-line arguments, the following example adds a second argument to my example above:
setup.exe /v"FILENAME=\"myfile.txt\"" /vSECONDARGUMENT=\"value2\""
