Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get installed applications in a system

How to get the applications installed in the system using c# code?

like image 728
Sauron Avatar asked May 26 '09 03:05

Sauron


People also ask

How can I get a list of programs installed on my computer?

Press Windows key + I to open Settings and click Apps > Apps & features. Doing so will list all programs installed on your computer, along with the Windows Store apps that came pre-installed.

How do I see all installed programs in Windows 10?

When it comes to viewing all installed apps on your Windows 10 PC, there are two options. You can use the Start menu or navigate to Settings > System > Apps & features section to view all installed apps as well as classic desktop programs.


1 Answers

Iterating through the registry key "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" seems to give a comprehensive list of installed applications.

Aside from the example below, you can find a similar version to what I've done here.

This is a rough example, you'll probaby want to do something to strip out blank rows like in the 2nd link provided.

string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; using(Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key)) {     foreach(string subkey_name in key.GetSubKeyNames())     {         using(RegistryKey subkey = key.OpenSubKey(subkey_name))         {             Console.WriteLine(subkey.GetValue("DisplayName"));         }     } } 

Alternatively, you can use WMI as has been mentioned:

ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Product"); foreach(ManagementObject mo in mos.Get()) {     Console.WriteLine(mo["Name"]); } 

But this is rather slower to execute, and I've heard it may only list programs installed under "ALLUSERS", though that may be incorrect. It also ignores the Windows components & updates, which may be handy for you.

like image 108
Xiaofu Avatar answered Sep 26 '22 05:09

Xiaofu