检测并需要在安装一个Windows QFE /补丁 [英] Detect and require a Windows QFE/patch for during installation

查看:254
本文介绍了检测并需要在安装一个Windows QFE /补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的WiX的安装部署一个.NET 4.0 WinForms应用程序到Windows Vista和Windows 7桌面。该应用程序包括一个需要的便携式类库:// WWW .microsoft.com /下载/ EN / details.aspx?ID = 3556>。NET补丁(KB2468871)。我们需要安装补丁作为先决条件。有迹象表明,可以应用补丁不同的方式:

Our WiX installer deploys a .NET 4.0 WinForms application to Windows Vista and 7 desktops. The application includes a Portable Class Library that requires a .NET patch (KB2468871). We need to install the patch as a prerequisite. There are various ways that the patch can be applied:


  1. 下载KB2468871补丁,并安装它

  2. 安装移植库工具

  3. 由于使用ClickOnce的先决条件(可能是#1的变化)

从的类似的问题,我创建了一个 CustomAction 来检查QFE(#1),我证实返回true时发现。

Using advice from a similar question, I created a CustomAction to check for the QFE (#1) that I demonstrated returns true when found.

private static bool IsPatchAlreadyInstalled()
{
    // If the patch is installed, we can find it using WMI
    var query = new SelectQuery("SELECT HotFixID FROM Win32_QuickFixEngineering WHERE HotFixID = 'Q2468871' OR HotFixID = 'KB2468871'");
    var results = new ManagementObjectSearcher(query).Get();
    return results.Count > 0;
}



不幸的是,失败我的开发机器上的补丁安装的一部分工具(#2)。我没有亲眼目睹的情况#3呢。

Unfortunately, this fails on my dev machine as the patch was installed as part of the Tools (#2). I haven't witnessed situation #3 yet.

什么是更好的方式是否已经应用补丁检测?

What is a better way to detect if the patch has been applied?

推荐答案

Win32_QuickFixEngineering 不会返回的所有更新。事实上,它返回仅限于QFE更新:

Win32_QuickFixEngineering won't return all updates. Actually, it returns only updates restricted to QFE:

更​​新由Microsoft Windows安装程序(MSI)或Windows
更新站点提供(http://update.microsoft.com)不受
Win32_QuickFixEngineering回来了。

Updates supplied by Microsoft Windows Installer (MSI) or the Windows update site (http://update.microsoft.com) are not returned by Win32_QuickFixEngineering.

你后更新是MSI补丁。使用 Microsoft.Deployment.WindowsInstaller (又名 DTF - 部署工具基金会 ,部分的 的WiX工具集 )来查询应用MSI补丁:

The update you're after is an MSI patch. Use Microsoft.Deployment.WindowsInstaller (aka DTF - Deployment Tools Foundation, part of the WiX toolset) to query the applied MSI patches:

public static bool IsPatchAlreadyInstalled(string productCode, string patchCode)
{
    var patches = 
        PatchInstallation.GetPatches(null, productCode, null, UserContexts.Machine, PatchStates.Applied);

    return patches.Any(patch => patch.DisplayName == patchCode);
}

在这种情况下,KB2468871是.NET Framework 4的更新之一。如果已应用在机器上的更新下面将返回true:

In this case, KB2468871 is one of .NET Framework 4 updates. The following will return true if the updates have been applied on the machine:

IsPatchAlreadyInstalled("{F5B09CFD-F0B2-36AF-8DF4-1DF6B63FC7B4}", "KB2468871");// .NET Framework 4 Client Profile 64-bit
IsPatchAlreadyInstalled("{8E34682C-8118-31F1-BC4C-98CD9675E1C2}", "KB2468871");// .NET Framework 4 Extended 64-bit
IsPatchAlreadyInstalled("{3C3901C5-3455-3E0A-A214-0B093A5070A6}", "KB2468871");// .NET Framework 4 Client Profile 32-bit
IsPatchAlreadyInstalled("{0A0CADCF-78DA-33C4-A350-CD51849B9702}", "KB2468871");// .NET Framework 4 Extended 32-bit

这篇关于检测并需要在安装一个Windows QFE /补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆