2013-04-26 70 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>