经过多次测试,我设法得到了答案
如果您在 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 和 Install Execute Sequence 以确保在抛出条件消息之前设置属性。
<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>