-2

I want to get the list of installed programs in the system in a string and their corresponding path in another string so that when I click on the name in list box that program should get executed. Here is the code that I've tried but it seems to give the names only but not location of the program.

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"));
        }
    }
}
Typist
  • 1,464
  • 9
  • 14
Rahul Vashishtha
  • 688
  • 6
  • 22
  • There are 900 zillion duplicates; this gets asked a couple of times a month or more. Please use the search feature. Do note that this is a foolhardy thing to attempt. Let applications manage their own uninstaller, unless you are writing an operating system. – Cody Gray - on strike Jun 18 '14 at 04:55

1 Answers1

0

That registry key will only have information related to Uninstall. It will not know the actual name or location of the program executable.

To get the list of Install Program with their executable path, use WMI. SO has a Similar question that can will help you

Community
  • 1
  • 1
Typist
  • 1,464
  • 9
  • 14