2011-05-07 83 views
2

在安装过程中,我必须安装一个取决于PC操作系统的外部驱动程序。我知道我可以为每个操作系统构建几个安装程序包,但我必须在一个安装程序中完成。那可能吗?WiX - 安装依赖于操作系统的驱动程序

我的第一个问题是找出PC上存在哪个操作系统。通过如下条件?

<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> 

然后如何告诉安装程序要执行哪个文件?

<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="Virtual_Driver" FileKey="vbsetup7" Execute="deferred" ExeCommand="" Return="check" Impersonate="no"/> 

回答

4

您必须将Condition添加到您的组件中。在运行时,Condition必须仅对其中一个组件元素评估为true,即条件必须互斥。例如:

<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> 
+0

第一个问题就解决了。谢谢 – Sabine 2011-05-08 14:35:41

0

你是如何安装驱动程序的?如果您使用的是DifxApp,那么您将必须拥有多个安装程序,每个目标体系结构(x86与x64)都有一个。 Difxapp有wixlib,使驱动程序的安装变得非常简单。

0

如果您必须在另一个“内部”运行一个安装程序,特别是如果第二个软件包也是基于Windows Installer的安装程序,则可能会出现问题,因为Windows Installer(MSI)不支持“嵌套”安装。 MSI使用的一些资源实际上是全球性的,因此内部安装可能会在正在进行的外部安装中发生变化。

更好的方法是使用安装链。在WiX中,这些被称为bundles,并由burn引导程序运行。您可以对包的每个元素应用条件,以便给定的元素仅针对特定的Windows版本(或服务包级别或x86 | x64)运行,或者如果系统上存在或不存在其他某个包,或...安装条件可以像你喜欢的那样灵活)。

相关问题