开发者

WiX - Install a driver which depends on the OS

During the installation, I have to install an external driver which depends on the operating system of the PC. I know I can build several installer packages for every OS, but I have to do it in one installer. Is that possible?

My first problem is to find out which operating system exists on the PC. Via a condition like the following?

<Condition Message="Your Operating system is ... .">
    VersionNT = 500
    <?define PCPlatform = "Win2000" ?>
    OR  VersionNT = 501
    <?define PCPlatform = "XP" ?>
    OR  VersionNT = 600
    <?define PCPlatform = "Vista" ?>
    OR  VersionNT = 601
    <?define PCPlatform = "Win7" ?>
</Condition>

And then how to tell the installer which file is to execute?

<Component Id="Win32_W2K" Guid="...">
    <File Id="vbsetup7" Source="..\driver\32Bit\W2K\vbsetup7.exe" Name="vbsetup7.exe" KeyPath="yes" DiskId="1"/>
</Component>
<Component Id="Win32_XP" Guid="...">
  <File Id="vbsetup7" Source="..\driver\32Bit\XP\vbsetup7.exe" Name="vbsetup7.exe" KeyPath="yes" DiskId="1"/>
</Component>
<Component Id="Win32_Vista" Guid="...">
  <File Id="vbsetup7" Source="..\driver\32Bit\Vista\vbsetup7.exe" Name="vbsetup7.exe" KeyPath="yes" DiskId="1"/>
</Component>
<Component Id="Win32_Win7" Guid="...">
  <File Id="vbsetup7" Source="..\driver\32Bit\Win7\vbsetup7.exe" Name="vbsetup7.exe" KeyPath="yes" DiskId="1"/>
</Component>
<CustomAction Id="Vi开发者_Go百科rtual_Driver" FileKey="vbsetup7" Execute="deferred" ExeCommand="" Return="check" Impersonate="no"/>


You have to add Condition to your components. At runtime, Condition must evaluate to true for only one of the component elements, that is, conditions must be mutually exclusive. Something like:

<Component Id="Win32_W2K" Guid="...">
    <Condition>VersionNT = 500</Condition>
    <File Id="vbsetup7" Source="..\driver\32Bit\W2K\vbsetup7.exe" Name="vbsetup7.exe" KeyPath="yes" DiskId="1"/>
</Component>


How are you installing the drivers? If you are using DifxApp then you will have to have more than one installer, one for each target architecture (x86 vs x64). There are wixlibs for Difxapp that make driver installation pretty easy.


You may have problems if you have to run one installer "inside" another, especially if the second package is also Windows Installer-based, because Windows Installer (MSI) does not support "nested" installs. Some of the resources that MSI works with are effectively global, so the inner installation can tromp on the outer-install-in-progress.

A better approach is to use a chain of installs. In WiX, these are called bundles, and are run by the burn bootstrapper. You can apply conditions to each element of the bundle, so that a given element is run only for a certain Windows version (or service-pack level, or x86|x64, or if some other package is or is not present on the system, or... Install conditions can be as flexible as you like).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜