Click here to Skip to main content
16,016,826 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to get the list all install application on the computer and execute it. I can get the list of application but cannot get their execute file.

I am using following code.

C#
string DisplayName = null;
string RegistryKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\UnInstall";

DataTable dt = new DataTable();
dt.Columns.Add("Software Name", typeof(string));
dt.Columns.Add("Software Version", typeof(string));
dt.Columns.Add("Software Publisher", typeof(string));
DataRow dr = null;

using (RegistryKey RegisrtyKey1 = Registry.LocalMachine.OpenSubKey(RegistryKey))
{
    foreach (var varName in RegisrtyKey1.GetSubKeyNames())
    {
        using (RegistryKey RegistryKey2 = RegisrtyKey1.OpenSubKey(varName))
        {
            DisplayName = Convert.ToString(RegistryKey2.GetValue("DisplayName"));
            if (DisplayName.Equals(""))
            {
                continue;
            }
            else
            {
                dr = dt.NewRow();
                dr[0] = (string)RegistryKey2.GetValue("DisplayName");
                if (RegistryKey2.GetValue("DisplayVersion") == null)
                    dr[1] = "";
                else
                    dr[1] = (string)RegistryKey2.GetValue("DisplayVersion");
                dr[2] = (string)RegistryKey2.GetValue("Publisher");
                dt.Rows.Add(dr);
            }
        }
    }
}
GridSoftwares.Columns.Clear();
GridSoftwares.DataSource = dt;
Posted
v2
Comments
Sergey Alexandrovich Kryukov 29-Apr-13 2:10am    
"I cannot..." does not make it a question is not informative. You need to explain the problem...
—SA
revolutionary.king 29-Apr-13 2:29am    
there is different applications install on computer like, MS Word,MS Excel etc. I just need all the list of these install applications in a grid and run them using c sharp application.
Sergey Alexandrovich Kryukov 29-Apr-13 2:44am    
I got it in first place. The place in the registry you are working with contains information for the uninstaller, not on the executable files. I'm not sure if it exists anywhere but link files created on installation. And if you interrogate the MSI, if any, you could get this information.
Why would you need to collect such information?
—SA
revolutionary.king 29-Apr-13 3:16am    
I am building an application to allow the limited user to view and run those applications which is administrator allow him to open.
Sergey Alexandrovich Kryukov 29-Apr-13 8:09am    
Any user can do this without such utility. When some applications are installed, they appear as links in the main menu. How come this is not enough?
—SA

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