Using Windows Installer Properties to Dynamically Modify IIS Settings

InstallShield 2013

Project: This information applies to the following project types:

Basic MSI
InstallScript MSI

For Basic MSI and InstallScript MSI projects, you can configure an IIS setting dynamically at run time through the use of Windows Installer properties. This enables you to let end users specify the name of the virtual directory, the TCP port, the site number, or other IIS settings for the Web sites, applications, virtual directories, application pools, and Web service extensions that they are installing on the target machine.

Windows Installer uses MsiFormatRecord to resolve the property at run time. The installation writes the property and its value to the following registry key so that the value is available during uninstallation and repair:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\InstallShield Uninstall Information\{ProductCode}

Therefore, if your Web site is installed to an end user–specified site number, the Web site, its applications, and its virtual directories can be successfully uninstalled from that site number.

Tip: If you do not want the IIS data to be stored in the registry, set the IS_IIS_DO_NOT_USE_REG property in your project.

If you use a property for any of the passwords in the Internet Information Services view, the passwords are encrypted when they are stored in the registry.

Example

The following procedure demonstrates how to let end users specify during installation the user name used for anonymous access to the Web site. Note that you can substitute a hard-coded value with a property for any of the IIS settings in the Internet Information Services view that allow you to enter characters. The property that you specify in this view must be enclosed within square brackets, and the property name must be all uppercase; for example, [MYPROPERTY].

Step 5 of the procedure is slightly different, depending on the project type, since Windows Installer controls the user interface of Basic MSI installations, and the InstallScript engine controls the user interface of InstallScript MSI installations.

To let end users specify the user name:

1. In the View List under Server Configuration, click Internet Information Services.
2. In the Web Sites explorer, click the Web site whose user name end users should be able to specify for anonymous access.
3. For the Enable anonymous access setting, select Yes.
4. In the Anonymous User Name setting, type the following:

[MYPROPERTY]

5. Use the property in a dialog. This part of the procedure depends on which project type you are using.
For Basic MSI projects:
a. In the View List under User Interface, click Dialogs.
b. In the Dialogs explorer, expand the All Dialogs folder, and click the language under the dialog that should contain the User Name control. As an alternative, you can add a new dialog.
c. Add an Edit Field control to the dialog, and set its Property property to the following:

MYPROPERTY

For InstallScript MSI projects:
a. In the View List under Behavior and Logic, click InstallScript.
b. Find the dialog code in the OnFirstUIBefore event for the dialog that should contain the User Name control, and add a call to the Windows Installer API function MsiSetProperty. For example, if you want the user name to be the name that the end user specifies on the CustomerInformation dialog, you would add an MsiSetProperty call as shown in the following lines of code:

Dlg_SdCustomerInformation:

    nResult = SdCustomerInformation(szTitle, svName, svCompany, nUser);

    MsiSetProperty(ISMSI_HANDLE, "MYPROPERTY", svName);

    if (nResult = BACK) goto Dlg_SdWelcome;

6. Build your release.

See Also