多的測試之後,我已經成功地得到答案
拋出一個消息,如果你是,你可以使用下面的條件語句在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>
嗨,我已經在Windows 2007系統上運行你所提供的代碼,現在出現95消息窗口。有沒有辦法將變量的值註銷到日誌中,這樣我就能明白爲什麼它沒有考慮到操作系統? – NRDargie 2013-04-26 12:20:32
你說Windows 2007?你究竟是什麼意思? – 2013-04-26 12:26:44
我在安裝了Service Pack 1的Windows 2007 Professional上運行安裝。當我運行上面的代碼時它會顯示Windows 95消息,如果它不顯示Windows 7消息? – NRDargie 2013-04-26 12:29:27