Saturday, June 16, 2007 11:01 AM
by
jamshedd
Registry Key based detection for .NET Framework and Visual Studio updates
There is often a need to have a way to detect whether or not a certain update for the .NET Framework or Visual Studio is installed on a PC. A user might easily go and look this up in ARP (Add-Remove Programs), but if you are an IT administrator for an enterprise you do not want to walk around and look this up one machine at a time for a few hundred or even a few thousand machines.
What you need in that case is a scriptable/deployable way of detecting whether the update is question is installed. One way to do this is by using registry key detection. Many of the updates Microsoft ships create entries in the registry that can be used to detect whether an update is installed or not. All updates for the .NET Framework 1.0, 1.1, 2.0, and 3.0 as well as Visual Studio .NET 2002, Visual Studio .NET 2003, and Visual Studio 2005 create these registry keys which may be used for detecting whether an update is installed - all you need is the KB number corresponding to the update you are trying to detect.
The format of the registry key varies slightly for different versions of the products and can be generalized as:
HKLM\Software\Microsoft\Updates\[Product]\[MajorVersion]\[identifier]
or
HKLM\Software\Microsoft\Updates\[Product-Version-SKU]\[KB Number]
Updates for the .NET Framework 1.0, .NET Framework 1.1, Visual Studio .NET 2002, and Visual Studio .NET 2003 use an identifier instead of the KB number. The identifier is simply the KB number with the prefix "KB" replaced by either an S (for Service Packs) or an M (for all other updates such as security updates, hotfixes, etc).
Updates for the .NET Framework 2.0, and Visual Studio 2005 use the KB number with the "KB" prefix retained.
Here's the list of registry keys for detecting updates for various versions of the .NET Framework as well as Visual Studio:
.NET Framework 1.0 : Hotfixes, Security Updates, and other updates
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\.NETFramework\1.0\M886906
.NET Framework 1.0 : Service Packs
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\.NETFramework\1.0\S867461
.NET Framework 1.1 : Hotfixes, Security Updates, and other updates
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\.NETFramework\1.1\M886903
.NET Framework 1.1 : Service Packs
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\.NETFramework\1.1\S867460
.NET Framework 2.0 : All Updates
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Microsoft .NET Framework 2.0\KB917283
Visual Studio .NET 2002 : Hotfixes, Security Updates, and other updates
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Visual Studio\7.0\M924642
Visual Studio .NET 2002 : Service Packs
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Visual Studio\7.0\S837234
Visual Studio .NET 2003 : Hotfixes, Security Updates, and other updates
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Visual Studio\7.1\M927696
Visual Studio .NET 2003 : Service Packs
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Visual Studio\7.1\S918007
Visual Studio 2005 : All Updates
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Microsoft Visual Studio 2005 Professional Edition - ENU\KB925674