Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried various codes for uninstalling software installed on current user by programmatically but failed each time. Please help to solve this ASAP...
Posted

 
Share this answer
 
Hi,

First of all THANKS to Rajesh & Deepankar for the great information links which helped me a lot.

I done my code by getting registry value of installed software on current user by "Registry.CurrentUser" because i didn't get it by "Registry.LocalMachine".
C#
private void Form1_Load(object sender, EventArgs e)
        {           
            this.Visible=false;
            this.Refresh();
            string AppName = "Acts Analysis";
            RegistryKey myRegKey = Registry.CurrentUser;
            myRegKey = myRegKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
            String[] subkeyNames = myRegKey.GetSubKeyNames();
            if (subkeyNames.Length > 0)
            {
                foreach (String s in subkeyNames)
                {
                    RegistryKey UninstallKey = Registry.CurrentUser;
                    UninstallKey = UninstallKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + s);
                    Object oValue = UninstallKey.GetValue("DisplayName");

                    if (oValue != null)
                    {
                        if (oValue.ToString() == AppName)
                        {
                            Process[] rundll32Processes = Process.GetProcessesByName("rundll32");
                            rundll32ProcessesCount = rundll32Processes.Length;
                            oValue = UninstallKey.GetValue("UninstallString");
                            oValue = oValue.ToString().Replace("rundll32.exe ", "").ToString();

                            Process p = new Process();
                            p.StartInfo.FileName = "rundll32.exe";
                            p.StartInfo.Arguments = oValue.ToString();
                            p.Start();
                            checkUI = false;
                            tmrFirstInput.Start();

                            break;
                        }
                    }
                }
            }
            else 
            {
                this.Close();
            }
        }
 
Share this answer
 

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