Answer
A complete installation package should be able to install an application on any version or type of Windows Operating System. Since the application or installation may use different resources or custom actions, you need to condition them based on the OS. This way, the installation package will only install the resources that meet the OS condition.
For this purpose, Windows Installer offers three built-in properties:
- Version9X - this property is set to the version number for Microsoft Windows 95, Windows 98 or Windows Me operating systems (it is empty when the OS is not one of these versions)
- VersionNT - this property is set to the version number for the NT operating systems (it is empty when the OS is not one of the NT versions: Windows NT, Windows 2000, Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008 or Windows 7)
- VersionNT64 - this property is set to the version number for the operating system only if the system is running on a 64-bit computer (it is empty if the package runs on a non-64 bit computer)
The values of the VersionNT property are:
- 500 for Windows 2000 and all its service packs
- 501 for Windows XP and all its service packs
- 502 for Windows Server 2003 and all its service packs
- 600 for Windows Vista (and its service pack) and Windows Server 2008
- 601 for Windows 7
If you need to know the exact number of the service pack installed,
you can use the ServicePackLevel property. Windows
Installer sets this property to the numerical value of the operating
system service pack level, if one is installed.
Install a component or run a custom action based on the Windows version
For the installation of a component you can set the Condition field in the Component Properties page to the Version9X or VersionNT property. The same condition can be set for a custom action in the Expression field of the Custom Action Properties page.
For example, if the component (or custom action) should be installed (or run) only on Windows 95/98/Me, the condition is:
Version9X
If the component (or custom action) should be installed (or run) only on Windows 2000, the condition is:
VersionNT=500
If the component (or custom action) should be installed (or run) only on Windows XP, the condition is:
VersionNT=501
If the component (or custom action) should be installed (or run) only on Windows Server 2003, the condition is:
VersionNT=502
If the component (or custom action) should be installed (or run) only on Windows Vista or Windows Server 2008, the condition is:
VersionNT=600
Install a component or run a custom action based on the Windows OS type (32-bit or 64-bit)
This can be done by using the VersionNT64 property in the "Condition" field for a component or the "Expression" field for a custom action.
If the component (or custom action) should be installed (or run) only on a 32-bit system, the condition is:
NOT VersionNT64
If the component (or custom action) should be installed (or run) only on a 64-bit system, the condition is:
VersionNT64