I am developing WPF application in C#. Currently my msi install the current application in machine.I need to uninstall two supporting application of existing version during
There is a option to uninstall the application using Windows Management Instrumentation (WMI). Using the ManagementObjectSearcher get the application needs to be Uninstalled and use the ManagementObject Uninstall method to uninstall the application.
ManagementObjectSearcher mos = new ManagementObjectSearcher(
"SELECT * FROM Win32_Product WHERE Name = '" + ProgramName + "'");
foreach (ManagementObject mo in mos.Get())
{
try
{
if (mo["Name"].ToString() == ProgramName)
{
object hr = mo.InvokeMethod("Uninstall", null);
return (bool)hr;
}
}
catch (Exception ex)
{
}
}
Detailed explanation given in Uninstalling applications programmatically (with WMI)