Desinstalar el programa

Estoy intentando desinstalar un programa con este código. Pero parece que no funciona. He intentado las otras respuestas pero tampoco parecía funcionar ... ¿Alguien puede ayudarme con esto? Estoy tratando de desinstalar el programa por un nombre determinado (displayName)

Por ejemplo, le doy el tee = = Appname, entonces este código debe desinstalar el programa Appname de mi computadora.

public static void UninstallApplictionInstalled(string p_name)
    {
        string displayName;
        string uninstlString;
        RegistryKey key;

        ProcessStartInfo info = new ProcessStartInfo();
        Process uninstallProcess = new Process();
        string temp;

        // search in: CurrentUser
        key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\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) == true)
            {

                uninstallProcess.StartInfo.FileName = "MsiExec.exe";
                uninstallProcess.StartInfo.Arguments = " /x " + uninstlString + " /quiet /norestart";
                uninstallProcess.Start();
                uninstallProcess.WaitForExit();
                break;

                //Console.WriteLine(subkey.GetValue("UninstallString"));
            }
        }

        // search in: LocalMachine_32
        key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\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) == true)
            {
                uninstallProcess.StartInfo.FileName = "MsiExec.exe";
                uninstallProcess.StartInfo.Arguments = " /x " + uninstlString + " /quiet /norestart";
                uninstallProcess.Start();
                uninstallProcess.WaitForExit();
                break;

                //Console.WriteLine(subkey.GetValue("UninstallString"));
            }
        }

        // 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) == true)
            {
                //string prdctId = uninstlString.Substring((uninstlString.IndexOf("{")));

                uninstallProcess.StartInfo.FileName = "MsiExec.exe";
                uninstallProcess.StartInfo.Arguments = " /x " + uninstlString + " /quiet /norestart";
                uninstallProcess.Start();
                uninstallProcess.WaitForExit();
                break;
                //Console.WriteLine(subkey.GetValue("UninstallString"));
            }
        }
      }

Solo esto aparece ..

Respuestas a la pregunta(1)

Su respuesta a la pregunta