2011-05-07 108 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)運行,或者如果系統上存在或不存在其他某個包,或...安裝條件可以像你喜歡的那樣靈活)。

相關問題