如何检查是否已从c#安装了Windows QFE /补丁?

时间:2008-09-11 20:38:31

标签: c# windows qfe

c#确定的最佳方法是安装了给定的QFE /补丁吗?

2 个答案:

答案 0 :(得分:2)

使用WMI并检查Win32_QuickFixEngineering枚举。

来自TechNet:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuickFixes = objWMIService.ExecQuery _
    ("Select * from Win32_QuickFixEngineering")
For Each objQuickFix in colQuickFixes
    Wscript.Echo "Computer: " & objQuickFix.CSName
    Wscript.Echo "Description: " & objQuickFix.Description
    Wscript.Echo "Hot Fix ID: " & objQuickFix.HotFixID
    Wscript.Echo "Installation Date: " & objQuickFix.InstallDate
    Wscript.Echo "Installed By: " & objQuickFix.InstalledBy
Next

您要检查HotFixID。

这是我系统上的输出:

    Hot Fix ID: KB941569
    Description: Security Update for Windows XP (KB941569)
    Hot Fix ID: KB937143-IE7
    Description: Security Update for Windows Internet Explorer 7 (KB937143)
    Hot Fix ID: KB938127-IE7
    Description: Security Update for Windows Internet Explorer 7 (KB938127)
    Hot Fix ID: KB939653-IE7
    Description: Security Update for Windows Internet Explorer 7 (KB939653)
    Hot Fix ID: KB942615-IE7
    Description: Security Update for Windows Internet Explorer 7 (KB942615)
    Hot Fix ID: KB944533-IE7
    Description: Security Update for Windows Internet Explorer 7 (KB944533)
    Hot Fix ID: KB947864-IE7
    Description: Hotfix for Windows Internet Explorer 7 (KB947864)
    Hot Fix ID: KB950759-IE7
    Description: Security Update for Windows Internet Explorer 7 (KB950759)
    Hot Fix ID: KB953838-IE7
    Description: Security Update for Windows Internet Explorer 7 (KB953838)
    Hot Fix ID: MSCompPackV1
    Description: Microsoft Compression Client Pack 1.0 for Windows XP
    Hot Fix ID: KB873339
    Description: Windows XP Hotfix - KB873339
    Hot Fix ID: KB885835
    Description: Windows XP Hotfix - KB885835
    Hot Fix ID: KB885836
    Description: Windows XP Hotfix - KB885836
    Hot Fix ID: KB886185
    Description: Windows XP Hotfix - KB886185
    Hot Fix ID: KB887472
    Description: Windows XP Hotfix - KB887472
    Hot Fix ID: KB888302
    Description: Windows XP Hotfix - KB888302
    Hot Fix ID: KB890046
    Description: Security Update for Windows XP (KB890046)

答案 1 :(得分:1)

最可靠的方法是确定哪些文件受QFE影响,并在每个文件上使用System.Diagnostics.FileVersionInfo.GetVersionInfo(path)并比较版本号。

编辑:我认为有一种方法可以检查注册表中的卸载信息,但是如果QFE成为可能报告错误否定的Service Pack或汇总包的一部分