多的测试之后,我已经成功地得到答案
抛出一个消息,如果你是,你可以使用下面的条件语句在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