2013-04-26 77 views
2

我試圖確定系統是否爲Windows Server 2008 R2。 Windows 7帶有相同的VersionNT號碼,所以我試圖使用MSINTProductType,但這個消息仍然在Windows 7系統上拋出。在WIX中獲取完整的操作系統名稱

此刻我的維克斯代碼:

<Condition Message="For windows 2008 R2 system application server role service is required> 
    VersionNT = 601 AND MsiNTProductType = 3 Not AppServer 
<Condition/> 

<Property Id="APPSERVER"> 
    <RegistrySearch Id="AppServerInstalled" 
        Root="HKLM" 
        Key="SOFTWARE\Microsoft\Windows\CurrentVersion" 
        Type="Raw"/> 
</Property> 

回答

1

http://wix.tramontana.co.hu/tutorial/getting-started/useful-extras

<Condition Message='Windows 95'>Version9X = 400</Condition> 
<Condition Message='Windows 95 OSR2.5'>Version9X = 400 AND WindowsBuild = 1111</Condition> 
<Condition Message='Windows 98'>Version9X = 410</Condition> 
<Condition Message='Windows 98 SE'>Version9X = 410 AND WindowsBuild = 2222</Condition> 
<Condition Message='Windows ME'>Version9X = 490</Condition> 
<Condition Message='Windows NT4'>VersionNT = 400</Condition> 
<Condition Message='Windows NT4 SPn'>VersionNT = 400 AND ServicePackLevel = n</Condition> 
<Condition Message='Windows 2000'>VersionNT = 500</Condition> 
<Condition Message='Windows 2000 SPn'>VersionNT = 500 AND ServicePackLevel = n</Condition> 
<Condition Message='Windows XP'>VersionNT = 501</Condition> 
<Condition Message='Windows XP SPn'>VersionNT = 501 AND ServicePackLevel = n</Condition> 
<Condition Message='Windows XP Home SPn'>VersionNT = 501 AND MsiNTSuitePersonal AND ServicePackLevel = n</Condition> 
<Condition Message='Windows Server 2003'>VersionNT = 502</Condition> 
<Condition Message='Windows Vista'>VersionNT = 600</Condition> 
<Condition Message='Windows Vista SP1'>VersionNT = 600 AND ServicePackLevel = 1</Condition> 
<Condition Message='Windows Server 2008'>VersionNT = 600 AND MsiNTProductType = 3</Condition> 
<Condition Message='Windows 7'>VersionNT = 601</Condition> 
+0

嗨,我已經在Windows 2007系統上運行你所提供的代碼,現在出現95消息窗口。有沒有辦法將變量的值註銷到日誌中,這樣我就能明白爲什麼它沒有考慮到操作系統? – NRDargie 2013-04-26 12:20:32

+0

你說Windows 2007?你究竟是什麼意思? – 2013-04-26 12:26:44

+0

我在安裝了Service Pack 1的Windows 2007 Professional上運行安裝。當我運行上面的代碼時它會顯示Windows 95消息,如果它不顯示Windows 7消息? – NRDargie 2013-04-26 12:29:27

0

個人而言,我不寫檢查Worksation VS Server作爲Windows的世界裏,他們基本上是相同的事情。例如,我有一臺運行帶有SQL Server 2012和TFS Server 2012的Windows 8的平板電腦。Win 8擁有所需的一切,如果安裝程序告訴我'您沒有運行服務器o/s 」。

如果您對某些只存在於服務器中的依賴關係,請編寫依賴項檢查。

+0

我遇到的問題是,只有當用戶運行在在Windows 2008 R2系統上,他們需要安裝應用程序服務器。在其他操作系統上,這不是必需的,因此我不希望消息出現,除非它是Windows 2008 R2系統。 – NRDargie 2013-04-26 13:29:57

0

多的測試之後,我已經成功地得到答案

拋出一個消息,如果你是,你可以使用下面的條件語句在Windows 2008 R2服務器上的工作。

<Condition Message="Windows Server 2008R2 installed"> 
     <NOT (VersionNT = 601 AND MsiNTProductType > 1)]]> 
    </Condition> 

我寫了一個自定義操作,然後確定是否安裝了應用程序服務器。

<CustomAction()> 
Public Shared Function CheckForAppServer(ByVal pobjSession As Session) As ActionResult 
    pobjSession.Log("Beginning Check for Application Server") 
    Dim lobjRegKey As RegistryKey 
    If Environment.Is64BitOperatingSystem Then 
     pobjSession.Log("64bit Opperating system detected") 
     lobjRegKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64) 
    Else 
     pobjSession.Log("32bit Opperating system detected") 
     lobjRegKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32) 
    End If 
    Dim lobjApplicationServerRegKey As Object = lobjRegKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\AppServer", True) 
    If lobjApplicationServerRegKey Is Nothing Then 
     pobjSession.Log("Application Server registry key not found") 
     pobjSession("APPSERVER") = "0" 
    Else 
     pobjSession.Log(lobjApplicationServerRegKey.ToString) 
     pobjSession.Log("Application Server registry key found") 
     pobjSession("APPSERVER") = "1" 
    End If 
    Return ActionResult.Success 
End Function 

負載在我的自定義操作和更新InstallUISequence並安裝執行順序,以確保屬性,都會設置將被拋出有條件的消息之前。

<InstallUISequence> 
     <Custom Action="CA_CheckForAppServer" Before="LaunchConditions" >NOT Installed</Custom> 
     </InstallUISequence> 
<InstallExecuteSequence> 
<Custom Action="CA_CheckForAppServer" Before="LaunchConditions" >NOT Installed</Custom> 
</InstallExecuteSequence> 

更新我有條件給以下

<Condition Message="Windows Server 2008R2 requires the application server to be enabled"> 
     <![CDATA[APPSERVER <> 0 OR NOT (VersionNT = 601 AND MsiNTProductType > 1)]]> 
     </Condition> 
相關問題