0

So I found the solution of getting a list of installed programs from here. Get installed applications in a system

But I wonder if I can get the installed directory of each of them? I need it because i would need to find all the executable files for that program.

Any suggestions would be appreciated.

Community
  • 1
  • 1
libra
  • 673
  • 1
  • 10
  • 30
  • Did you try checking the subkeys' `InstallLocation` value - it should be present at least for non driver/printer/etc. stuff. – Filburt Mar 22 '17 at 10:05

1 Answers1

0

You need to find all installed app from "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" Here is the sample code

private string FindByDisplayName(RegistryKey parentKey, string name)
    {
        string[] nameList = parentKey.GetSubKeyNames();
        for (int i = 0; i < nameList.Length; i++)
        {
            RegistryKey regKey =  parentKey.OpenSubKey(nameList[i]);
            try
            {
                if (regKey.GetValue("DisplayName").ToString() == name)
                {
                    return regKey.GetValue("InstallLocation").ToString();
                }
            }
            catch { }
        }
        return "";
    }

RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
string location = FindByDisplayName(regKey, "MSN");
MessageBox.Show(location);

This example will compare the DisplayName keyvalue to your input name, if it find the value, then return the InstallLocation key value.

Sincerely,

Thiyagu Rajendran

**Please mark the replies as answers if they help and unmark if they don't.