Click here to Skip to main content
15,888,177 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all
i want to fetch install location of all products in my app so for that purpose i am using registry class and using below string value for it
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\UnInstall"
and
"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\UnInstall" for 64 bit version.
but it is not giving me details of all products for example
notepad ++ available in above path in registry editor but using my code it is not displaying the values for notepad.

What I have tried:

below is my code

<pre>  StreamWriter sw = new StreamWriter(@"D:\localmachineProducts64.txt", true);
            using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
            {
                foreach (string skName in rk.GetSubKeyNames())
                {
                    using (RegistryKey sk = rk.OpenSubKey(skName))
                    {
                        try
                        {
                            sw.Write(sk.GetValue("DisplayName") + "\t" + sk.GetValue("InstallLocation"));
                            sw.Write(sw.NewLine);
                            count++;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
                sw.Write("Total count  :=" + count);
            }
            sw.Close();
Posted
Updated 2-Dec-17 9:42am
Comments
Richard MacCutchan 2-Dec-17 9:39am    
Go and look in the registry to see what information is there. Not all products will insert all fields.
Richard Deeming 5-Dec-17 12:13pm    

1 solution

You're making the most egregious of mistakes. Your ASSUMING that the value you want is in every one of the keys under the Uninstall key. It's not.

It's impossible to get the installed location of every application listed.

Also, not every application that's installed even shows up under the Uninstall key!
 
Share this answer
 
Comments
sumitk.cadc 3-Dec-17 7:40am    
hi Dave,
Thanks for your comment.
my requirement is i want to check the install location of any product.
so can you help me out how i can achieve this.
or in HKEY_LOCAL_MACHINE\SOFTWARE or HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node
i want to search the name of "Product Folder" and if it is there then i want to read all the values.
For example i want to check McAfee product's folder location in Registry node
Dave Kreskowiak 3-Dec-17 9:33am    
Your "requirement" is wishful thinking. There is no way to get the information you want on every application.

You tried to find "Notepad". Well, it was never "installed". The executable was laid down when Windows was installed. There is no information for it stored anywhere.

MSI installers CAN put their InstalledPath path under the Uninstall key. There is no requirement that say they have to. The install path is calculated by most MSI's at install/uninstall time, so there really isn't any need to put an InstallPath in the registry.

Executable installers don't have to put anything at all under the Uninstall key and typically don't. There's usually nothing in the registry at all about them.

The data you want simply doesn't exist!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900