This question is an exact duplicate of:
- Uninstalling program 1 answer
If I run the code below I'm pretty sure I'm supposed to get the Product Name and GUID (ex. App Path | {xxx}) for the application. But I'm only getting the path and no GUID is shown. Can someone help me?
// search in: LocalMachine_64
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
foreach (String keyName in key.GetSubKeyNames())
{
RegistryKey subkey = key.OpenSubKey(keyName);
displayName = Convert.ToString(subkey.GetValue("DisplayName"));
uninstlString = Convert.ToString(subkey.GetValue("UninstallString"));
if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine(subkey.GetValue("UninstallString"));
//string prdctId = uninstlString.Substring((uninstlString.IndexOf("{")));
string prdctId = uninstlString.Substring(12);
uninstallProcess.StartInfo.FileName = "MsiExec.exe";
uninstallProcess.StartInfo.Arguments = " /x " + prdctId + " /quiet /norestart";
uninstallProcess.StartInfo.UseShellExecute = true;
uninstallProcess.Start();
uninstallProcess.WaitForExit();
break;
//Console.WriteLine(subkey.GetValue("UninstallString"));
}
}
This is the image that I got running the code