แก้ไข

แชร์ผ่าน


How to determine which .NET Framework security updates and hotfixes are installed

This article shows you how to find out which .NET Framework security updates and hotfixes are installed on a computer.

Update history

To see which .NET Framework updates are installed on your own computer, in Settings, navigate to Windows Update > Update history. Look under the Quality Updates section for .NET Framework updates. For example, you might see an update similar to "2023-11 Cumulative Update for .NET Framework 3.5 and 4.8.1 for Windows 11, version 22H2 for x64 (KB5032007)".

Registry

You can query the registry using Registry Editor, code, or PowerShell.

Note

All the registry techniques require an account with administrative privileges.

Use Registry Editor

The installed security updates and hotfixes for each version of the .NET Framework installed on a computer are listed in the Windows registry. You can use the Registry Editor (regedit.exe) program to view this information.

  1. Open the program regedit.exe. In Windows 8 and later versions, right-click Start Screenshot of the Windows key logo., then select Run. In the Open box, enter regedit and select OK.

  2. In the Registry Editor, open the following subkey:

    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates

    The installed updates are listed under subkeys that identify the .NET Framework version they apply to. Each update is identified by a Knowledge Base (KB) number.

In the Registry Editor, the .NET Framework versions and installed updates for each version are stored in different subkeys. For information about detecting the installed version numbers, see How to: Determine which .NET Framework versions are installed.

Query using code

The following example programmatically determines the .NET Framework security updates and hotfixes that are installed on a computer:

using System;
using Microsoft.Win32;

public class GetUpdateHistory
{
    public static void Main()
    {
        using (RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(@"SOFTWARE\Microsoft\Updates"))
        {
            foreach (string baseKeyName in baseKey.GetSubKeyNames())
            {
                if (baseKeyName.Contains(".NET Framework"))
                {
                    using (RegistryKey updateKey = baseKey.OpenSubKey(baseKeyName))
                    {
                        Console.WriteLine(baseKeyName);
                        foreach (string kbKeyName in updateKey.GetSubKeyNames())
                        {
                            using (RegistryKey kbKey = updateKey.OpenSubKey(kbKeyName))
                            {
                                Console.WriteLine("  " + kbKeyName);
                            }
                        }
                    }
                }
            }
        }
    }
}

Imports Microsoft.Win32

Public Class GetUpdateHistory
    Public Shared Sub Main()
        Using baseKey As RegistryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\Microsoft\Updates")
            For Each baseKeyName As String In baseKey.GetSubKeyNames()
                If baseKeyName.Contains(".NET Framework") Then
                    Using updateKey As RegistryKey = baseKey.OpenSubKey(baseKeyName)
                        Console.WriteLine(baseKeyName)
                        For Each kbKeyName As String In updateKey.GetSubKeyNames()
                            Using kbKey As RegistryKey = updateKey.OpenSubKey(kbKeyName)
                                Console.WriteLine("  " & kbKeyName)
                            End Using
                        Next
                    End Using
                End If
            Next
        End Using
    End Sub
End Class

The example produces an output that's similar to the following one:

Microsoft .NET Framework 4 Client Profile
  KB2468871
  KB2468871v2
  KB2478063
  KB2533523
  KB2544514
  KB2600211
  KB2600217
Microsoft .NET Framework 4 Extended
  KB2468871
  KB2468871v2
  KB2478063
  KB2533523
  KB2544514
  KB2600211
  KB2600217

Query using PowerShell

The following example shows how to determine the .NET Framework security updates and hotfixes that are installed on a computer using PowerShell:

$DotNetVersions = Get-ChildItem HKLM:\SOFTWARE\WOW6432Node\Microsoft\Updates | Where-Object {$_.name -like
 "*.NET Framework*"}

ForEach($Version in $DotNetVersions){

   $Updates = Get-ChildItem $Version.PSPath
    $Version.PSChildName
    ForEach ($Update in $Updates){
       $Update.PSChildName
       }
}

The example produces an output that's similar to the following one:

Microsoft .NET Framework 4 Client Profile
KB2468871
KB2468871v2
KB2478063
KB2533523
KB2544514
KB2600211
KB2600217
Microsoft .NET Framework 4 Extended
KB2468871
KB2468871v2
KB2478063
KB2533523
KB2544514
KB2600211
KB2600217

See also