Using MSI Launch Conditions to Prevent Installation on Unsupported Windows Platforms

Before Windows 7, support for 64-bit Windows was not really a concern for most applications because they were aimed squarely at the 32-bit Windows market.  With Windows 7, a large percentage of Windows users will be using the 64-bit version, which means that your setup program has to know what to do when it encounters 64-bit Windows.  If your software only works on certain versions of Windows, you should be using launch conditions to prevent users from installing it on unsupported platforms.

I’ve created several launch conditions that you might want to use in your setups.  To keep things easy, I have organized the launch conditions using the table format of the LaunchCondition table in the InstallShield Direct Editor.

Example 1: Preventing Installation on 64-Bit Windows

In this example, the application will only work on 32-bit versions of Windows.  Therefore, the launch condition could be something like this:

Condition

Description

Not VersionNT64

[ProductName] will only work on 32-bit versions of Windows.  Please run the setup on 32-bit Windows.  Setup will now exit.

Example 2: Preventing Installation on 32-Bit Windows

This is the converse of Example 1. That is, the application requires 64-bit Windows and it will not run on 32-bit Windows.

Condition

Description

VersionNT64

[ProductName] will only work on 64-bit versions of Windows.  Please run the setup on 64-bit Windows.  Setup will now exit.

Example 3: Handling Multiple Versions of Windows with Different Service Packs

In this example, the application will run on three versions of Windows and each should have certain service packs.  The first condition (VersionNT >= “501”) prevents the end user from running the setup on Windows 2000 or Windows NT.  The last three conditions apply to only specific versions of Windows.  So if the setup runs on Windows Vista (VersionNT = “600), for example, the first, second, and fourth conditions will always return true, and the third condition will only return true if Service Pack 2 or later is installed.

Condition

Description

VersionNT >= “501”

[ProductName] requires Windows XP, Windows Vista, Windows 7, or a later version of Windows.  Setup will now exit.

(VersionNT = "501" And ServicePackLevel >= "3") Or VersionNT <> "501"

[ProductName] requires Windows XP Service Pack 3 or later.  Setup will now exit.

(VersionNT = "600" And ServicePackLevel >= "2") Or VersionNT <> "600"

[ProductName] requires Windows Vista Service Pack 2 or later.  Setup will now exit.

(VersionNT = “601” And ServicePackLevel >= “1”) Or VersionNT <> “601”

[ProductName] requires Windows 7 Service Pack 1 or later.  Setup will now exit.

Example 4: Ensuring the Setup Has Sufficient Privileges

Most setups install files to privileged locations such as the Program Files folder or the System folder.  And most setups also write to HKEY_LOCAL_MACHINE or HKEY_CLASSES_ROOT in the registry.  These locations require administrative privileges.  The best way to check for these privileges is to use the Privileged condition:

Condition

Description

Privileged

[ProductName] requires administrative privileges or elevated privileges.  Setup will now exit.

Launch Conditions in Windows Installer (MSI) are a great way to make sure that end users run the setup only on supported platforms. To take this idea further, you can also combine a System Search with a launch condition to check for required software or registry entries. The possibilities are numerous and correct use of launch conditions can really improve a setup.

6 comments on “Using MSI Launch Conditions to Prevent Installation on Unsupported Windows Platforms

  1. Chrpai on   # Reply

    I’ve often wondered why http://msdn.microsoft.com/en-us/library/aa372039(VS.85).aspx suggests that LaunchConditions should be scheduled before AppSearch. Also I find it useful to suffix many of my conditions with “or Intsalled” to prevent problems on subsequent operations such as Uninstall.

  2. Alan Burns on   # Reply

    Although the suggested InstallUISequence table shows that the LaunchConditions action precedes the AppSearch action, our development team changed the order so that AppSearch would come first, probably after realizing that making this change allows the LaunchConditions action to check for conditions based on the results of AppSearch. I suspect that Microsoft’s early implementation of Windows Installer made the LaunchConditions action the first one in the sequence because you have to be sure the setup is able to run before doing anything else. AppSearch, however, is an exception, and the documentation for the LaunchConditons action actually says that “the AppSearch Action may be sequenced before the LaunchConditons action.”

    With respect to adding “Or Installed” to selected launch conditions, that is a good thing to do if the LaunchConditions action is conditioned to run during all installation modes (install, repair, maintenance, and uninstall). InstallShield takes a different approach by adding the “Not Installed” condition to the LaunchConditions action. That way, the launch conditions are only considered during a first time install, and ignored for maintenance, repair, and uninstall. After all, once the product is installed, you never want to prevent the cached MSI from running because that might prevent it from uninstalling the product.

  3. Ferdi on   # Reply

    Alan, you perhaps should update the article and mention XP64 with “502”, most people don’t know that and will be surprised. I was, when I first encountered it

    Cary, You do not need VersionNT64 in your Conditions, VersionNT is enough for both targets

    (MsiNTProductType=1 AND (VersionNT=501 OR VersionNT=502) AND ServicePackLevel>=2) OR (MsiNTProductType>1 AND VersionNT=502 AND ServicePackLevel>=2) OR VersionNT>=600

    Windows XP SP2 and higher
    Windows Vista
    Windows 7
    Windows Server 2003 SP2 and higher
    Windows Server 2008
    Windows Server 2008 R2

    (MsiNTProductType>1 AND VersionNT=502 AND ServicePackLevel>=2) OR (MsiNTProductType>1 AND VersionNT>=600)

    Windows Server 2003 SP2 and higher
    Windows Server 2008
    Windows Server 2008 R2

  4. Christopher Painter on   # Reply

    As an aside, we stopped using LaunchConditions years ago. We found it annoying that it could only display one error message at a time, had no concept of informational/warning messages, had no way or ordering the messages and looked like a very boring messagebox. It actually wasn’t that much work to create a custom table, custom action and dialog. I wish InstallShield had this built-in.

  5. Tobias S1979 on   # Reply

    The above mentioned launch conditions are partially not correct. As a sample:

    (VersionNT = “601” And ServicePackLevel >= “1”) Or VersionNT “601”

    [ProductName] requires Windows 7 Service Pack 1 or later. Setup will now exit.

    The installer with this launch Con will also runs on WinXP and not as stated only on Win7 and higher

  6. Kevins on   # Reply

    Since I needed this, I’ll post one little note based on what Tobias sais.

    Add a condition like ‘VersionNT >= “601”‘ to restrict installs to only OS’s Windows 7 and newer.

Leave a Reply

Your email address will not be published. Required fields are marked *