Search code examples
c#windowscomregistry

C# Querying Software Update History


I am writing a C# console application which collects data about a machine and writes it to an external database. One of the bits of information it is necessary to collect is information about the software that is installed. There is a set of specific pieces of software we have that we would like to know about. Specifically which ones are installed, which versions are installed, and which patches they have had applied.

I have managed to acquire the information about which software is installed, and which versions they are, by querying the registry. However, when it comes to figuring out which patches are installed I am a little stumped.

I know that if I go to Control Panel -> Programs -> View installed updates I can see the patches I have installed for these software (specifically, it gives me the exact patch number - ie, Patch 21). So, I would like something similar. I found WUApiLib and thought it would be the answer to my problems, but when I query the update history all that is returned is a list of Microsoft updates to the OS, .NET, Visual Studio etc. There is no mention of the patches I applied to our software.

I am not very familiar with how patching works, but I believe the patches use msp file format, so I think the information should be logged by Windows somewhere. How does Control Panel get it? Where might I be able to get it? The registry entries under HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall do not mention patches at all.


Solution

  • So, after some digging around I found a different part of the registry which lists all the information I needed.

    HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products
    

    This contains the name and version of software installed (under <GUID>\InstallProperties) and patches installed for each (under <GUID>\Patches)