InstallShield Tips and Techniques

April 15, 2012

Running your application setup silently

Filed under: Reference Materials — shieldmaster @ 1:27 am

The advantage of using the InstallShield project type “Basic MSI” is that the ability to run silently is built-in!

When running silently, it implies that the dialogs are not being displayed – consequently there is no ability for the customer to customize the application configuration, only the default values defined within the application package would be used.

User provided command parameters

This means that when a customer wants to provide configuration data, there must be a solution. The solution is to provide a parameter for each MSI Property that is associated with a dialog data entry value. For example, since all of the dialog data fields are tied to MSI Properties  – an example is the MSI Property “INSTALLDIR” for the user modifiable installation directory, when you run silently, you would just provide the user selected data values using a format like this:

msiexec /i “c:\install\Setup.msi” /qb INSTALLDIR=”c:\Program Files\ISI Software

 

“c:\install\Setup.exe” /V” /qb INSTALLDIR=”c:\Program Files\ISI Software

 

Notes: 

  • the “/i” indicates an normal MSI installation,
  • the “/qb” indicates the user dialogs are suppressed, i.e., run with basic progress bar. If you did not include the /q parm, the dialogs would appear with the values supplied via the command parms – a good way to validate the fields before production!
  • the value for the MSI Property INSTALLDIR is the value supplied within quotes – due to embedded spaces.
  • /V” is the method to pass the command line parameters into the setup executable (not needed for .MSI files)

 

The only non-user friendly aspect to this method is that all of the MSI Properties would need to be on a continuous line, so a large amount of data fields would need to be entered similar to this:  (Line breaks accomplished by editor automatically)

msiexec /i “c:\install\Setup.msi” /qb INSTALLDIR=”c:\Program Files\ISI Software” ADVANCED=”TRUE” BRONZE=”FALSE” DISCRETE =”FALSE” PAPER_MACHINE=”YES” GOLD_FIBER=”YES” GOLD_RECOVERY=”NO” PAPER_BOARD=”TRUE”

 

Determining your data field command parameters

For example, if we evaluate this dialog screen within the InstallShield project:


 

We see six data entry fields to be specified on this dialog, with the highlighted data field shown is associated with the property “ISI_ADMINEMAIL”

(Note: all MSI properties used to be passed thru as parameters must be in all Capital letters!).

So all of the MSI Properties represented on this dialog screen are:

ISI_ADMINEMAIL

ISI_MAILHOST

ISI_MAILUSER

ISI_MAILPASSWORD

ISI_MAILPORT

ISI_MAILUSESSL

 

In order to pass the command parameters, we would use either of these formats, based on whether you were executing a .MSI or .EXE setup:

“C:\Install\RBSetup.msi” /qb

INSTALLDIR=”c:\Program Files\ISI Software” ISI_ADMINEMAIL=”admin@gmail.com”

ISI_MAILHOST=”smtp.gmail.com”

ISI_MAILUSER=”charles@gmail.com”

ISI_MAILPASSWORD=”mypassword”

ISI_MAILPORT=”465″

ISI_MAILUSESSL=”TRUE”

 

:

 

“C:\Install\RBSetup.exe” /V” /QB

INSTALLDIR=”c:\Program Files\ISI Software” ISI_ADMINEMAIL=”admin@gmail.com”

ISI_MAILHOST=”smtp.gmail.com”

ISI_MAILUSER=”charles@gmail.com”

ISI_MAILPASSWORD=”mypassword”

ISI_MAILPORT=”465″

ISI_MAILUSESSL=”TRUE”

 

Option #1: Use System Search to reading in command parameters via XML document

 

One option to read in the Command parameters is via an XML document that has been pre-staged in a specific area on the User’s desktop. In our example, we are pre-positioning a file “CFG.XML” onto the user’s Local App Data directory. The format of the CFG.XML document is:

<?xml version=”1.0″ encoding=”utf-8″?>

<QUINTREX>

<MSIPARMS>

<PREREQCHECK TYPE=”STRING”>Bypass</PREREQCHECK>

<INSTALLDIR

    TYPE=”STRING”>c:\ISI Software

</INSTALLDIR>

<ISI_ADMINEMAIL

TYPE=”STRING”>admin@gmail.com

</ISI_ADMINEMAIL>

<ISI_ MAILHOST

TYPE=”STRING”>smtp.gmail.com

</ISI_ MAILHOST>

<ISI_MAILUSER

TYPE=”STRING”>charles@gmail.com

</ISI_MAILUSER>

<ISI_MAILPASSWORD

TYPE=”STRING”>mypassword

</ISI_MAILPASSWORD>

<ISI_MAILPORT

TYPE=”STRING”>465

</ISI_MAILPORT>

<ISI_MAILUSESSL

TYPE=”STRING”>TRUE

</ISI_MAILUSESSL>

</MSIPARMS>

</QUINTREX>

 

On a Windows 7 machine this file will be pre-positioned in the following directory: “C:\Users\<$Charles$>\AppData\Local\Quintrex” – which is accessible via the InstallShield’s directory property “[LocalAppDataFolder]Quintrex”.

On a Windows XP, this directory would be: “C:\Documents and Settings\<$Charles$>\Application\Quintrex”

The sample InstallShield project will have a XML System Search that will access each installation command path and store into the correct MSI Property. Here is a sample dialog:

 

 

 

Notes:

  1. The directories that the CFG.XML can be stored on the desktop are limited, the AppSearch Standard Action happens before the Directory table is resolved, so you can only use the Windows Installer directories, such as:
  • TempFolder
  • WindowsVolume
  • Windows
  • LocalAppDataFolder

The System Search cannot use directories that you have created to install your application, such as [INSTALLDIR] because the Directories have not been defined when the AppSearch Standard Action has been run

 

  1. The value retrieved for the Installation directory cannot directly be used for the INSTALLDIR value. You must retrieve it, store as a MSI Property. Then you will need to create a Type 35 Custom Action “Set a Directory” that will then read in the MSI property and set [INSTALLDIR]. The modification of the System Search to set a property and use a Condition.

     

     

     

     

     

     

     

     

     

     

     

Option #2: Use InstallScript Custom Action to read in command parameters

 

Finally, you can create an InstallScript Custom Action that will read in a INI formatted file that exists in the same directory as the setup. This will allow you to have an easier solution that can be maintained more easier by future InstallShield developers.

 

Here is an example of a INI file:

[ISI Application]

DIR=C:\Program Files\ISI Software

ADMINEMAIL=admin@gmail.com

MAILHOST=smtp.gmail.com

MAILUSER=charles@gmail.com

MAILPASSWORD=mypassword

MAILPORT=465

MAILUSESSL=TRUE

 

Here is a sample InstallScript that will read the INI file and populate the correct MSI properties

 

//Setup the INI file parms

szSectionName = “ISI Application”;

szKeyName = “ADMINEMAIL”;

 

if (GetProfString (szIniFilePath, szSectionName,

            szKeyName, svAdminEmail) != 0) then

 

    // Log an error message if the string

    // could not be retrieved.

    ISI_WriteLogFile

        (“ISI–> ERROR – Could not get the ” +

        szKeyName + ” entry from the ” +

        szSectionName +

        “section of the ISIAppSilent.ini.”);

else

    // Log the key and its current value.

    ISI_WriteLogFile

        (“ISI–> INFO – Admin Email value = ” +     

        svAdminEmail);

endif;

 

// Set the MSI Properties based on the info

// from the .ini file.

MsiSetProperty(ISMSI_HANDLE, “ISI_ADMINEMAIL”, svAdminEmail);

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: