【问题标题】:Get full operating system name in WIX在 WIX 中获取完整的操作系统名称
【发布时间】:2013-04-26 11:04:00
【问题描述】:

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

【问题讨论】:

    标签: wix


    【解决方案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>
    

    【讨论】:

    • 您好,我已经运行了您提供的代码,现在 windows 95 消息出现在 windows 2007 系统上。有没有办法将变量的值注销到日志中,这样我就可以看到为什么它似乎没有考虑到操作系统?
    • 你说的是Windows 2007?你到底是什么意思?
    • 我正在安装了 Service Pack 1 的 Windows 2007 Professional 上运行安装。当我运行上面的代码时它会显示windows 95的消息,它不应该显示windows 7的消息吗?
    • 抱歉 windows 7 Professional with Service Pack 1
    【解决方案2】:

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

    如果您对仅在服务器中的某些内容有依赖关系,请为此编写依赖关系检查。

    【讨论】:

    • 我遇到的问题是,仅当用户在 Windows 2008 R2 系统上运行时才需要依赖项,此时他们需要安装应用程序服务器。在其他操作系统上,这不是必需的,因此我不希望出现该消息,除非它是 Windows 2008 r2 系统。
    【解决方案3】:

    经过大量测试,我设法得到了答案

    如果您在 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-01
      • 2015-05-25
      • 1970-01-01
      • 2019-01-19
      • 1970-01-01
      • 2012-06-04
      • 2017-06-15
      相关资源
      最近更新 更多