In Your button click event use the below code:
One Caveat: In 32-bit os, the code can be used as it is but in a 64-bit os,
you have to set the 'Target CPU' to x86 (instead of AnyCPU).
RegistryKey rgKey = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
ProcessStartInfo info = new ProcessStartInfo();
Process uninstallProcess = new Process();
var ns = rgKey.GetSubKeyNames().Where(n => n.ToLower().Contains("cricket"));
if(ns.Count() > 0)
{
foreach (var vsKey in rgKey.GetSubKeyNames())
{
RegistryKey productKey = rgKey.OpenSubKey(vsKey);
string dispName = Convert.ToString(productKey.GetValue("DisplayName"));
string uninstlString = Convert.ToString(productKey.GetValue("UninstallString"));
if (dispName.ToLower().Contains("cricket"))
{
string prdctId = uninstlString.Substring((uninstlString.IndexOf("{")));
uninstallProcess.StartInfo.FileName = "MsiExec.exe";
uninstallProcess.StartInfo.Arguments = " /x " + prdctId + " /Qn";
uninstallProcess.Start();
break;
}
}
}