在WIX中获取完整的操作系统名称

时间:2013-04-26 11:04:01

标签: wix

我正在尝试确定系统是否是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>

3 个答案:

答案 0 :(得分: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>

答案 1 :(得分:0)

就个人而言,我不会为Worksation vs Server编写检查,因为在Windows世界中它们基本上是相同的。例如,我有一台运行带有SQL Server 2012和TFS Server 2012的Windows 8的平板电脑.Win 8拥有所需的一切,如果安装程序告诉我'你没有运行服务器o / s,那将会很烦人”。

如果您只依赖于服务器中的某些内容,请编写相关的依赖项检查。

答案 2 :(得分: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和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>