SQlBeginner
SQlBeginner

Reputation: 75

Program still listed in Control Panel after uninstalling

I am trying to uninstall a program with a C# application and everything works except the program is still listed in the Control Panel Programs & Features.

It also does this when I uninstall from the command line using wmic.

The program is uninstalled, but I still have to actually click the name in control panel programs & features for a window to pop up and tell me it has uninstalled. After that, it is gone for good. How can I bypass having to go into control panel to completely remove it. I need it to be uninstalled and not listed in control panel.

This is my code to uninstall which appears to be correct:

string programName = "myProgram";
ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Product");

foreach (ManagementObject mo in mos)
{
    if (mo["name"].ToString().Contains(programName))
    {
        mo.InvokeMethod("Uninstall", null);
        MessageBox.Show(mo["name"].ToString() + " uninstalled");
    }
}

Upvotes: 4

Views: 4511

Answers (1)

Aakash
Aakash

Reputation: 9

Check the log for uninstall and if the it is successful and even after a refresh i.e. F5 the entry is still present in Control Panel, for the product which is to be uninstalled delete the registry entry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\

Upvotes: -1

Related Questions