In last Friday's post, we introduced the idea of response file variables. Today I want to talk about how you add variables to your response files and how you use them to drive deployments. So let's get started!
What do variables in a response file look like?
There are two parts to including variables in your response files.
First, you need to add a <variables> section to your response file. This is where you define the names of the variables and default values for those variables. It will look something like this:
<variables>
<variable name="installPath" value="C:\installPath"/>
</variables>
Once you've defined the variables, you then need to reference them in the XML elements that define what will happen in your install. An example would be the following, using the variable we defined previously:
<profile id="myProfile" installLocation="${installPath}">
In this case, we've used a variable to define where this profile gets installed to on the system. We've also given it a default path to use in case we don't specify something when calling this response file.
Using response file variables during silent install
So we've added in a variable, and we're using it to define our install path. But how do I invoke this response file and pass a value to the variable? Glad you asked! This is straightforward:
In this case, we're invoking imcl.exe, giving it our response file that defines the install we want to perform, and have told it we have a variable we want to provide a value for. In this case, we have just one variable with one value.
Adding variables to your response files
There are two ways to add variables to your response files. You can record a new response file, and let Installation Manager create a "variables" section in the response file for you. It will add some variables to this section based on your inputs while recording, based on whether you override the default values.
The other approach, and one you'll likely have to use to handle some of the variables you'll want to define, is to hand edit the response file. This is a straightforward process, since the response file is just an XML file. Using your favorite XML editing tool, open the file and add the elements you would like.
Going further...
There are two other items to mention in this context. These are IF statements and predefined variables.
IF Statements
IF statements in these variables are used for setting values based on another variable's value. This allows you to conditionalize a value based on one or more other variables or properties. This can be useful for defining your install location based on platform and architecture, or your feature selection based on a "role" property you pass in. For example:
<variables>
<variable name='languages' value='en,fr'/>
<variable name='installDir' value='/opt/foo'>
<if name='platform:os' equals='win32' value='C:\Foo'/>
<if name='platform:os' equals='linux'>
<if name='platform:arch' equals='x86' value='/opt/foo_x86'/>
<if name='platform:arch' equals='ppc' value='/opt/foo_ppc'/>
</if>
</variable>
</variables>
In this example, we have the variable "installDir" changing its value based on the OS, and for the OS "linux" we're also basing it on the architecture.
Predefined Variables
One thing you may have noticed in that previous example was that we referenced variables that weren't defined in our variables section. Installation Manager comes with several predefined variables you can use in these conditional statements to handle checking for common conditions. As we saw above, this includes both the OS and platform, but also the current language, the host name of the machine, as well as the user's name. A full list of these predefined variables can be found on the Response file variables page in the Installation Manager Info Center.
Conclusion
As you can see, response file variables give you quite a bit of power in making your silent installs more flexible, while still being able to have a common template for product installs. If you have any questions, feel free to post in the comments section.