static public void Uninstall() { try { if (InstalledSoftware.NameContain("teamviewer", "msi")) { Process process = new Process(); process.StartInfo.WorkingDirectory = TeamViewer.Path; process.StartInfo.FileName = string.Format(TeamViewer.Path + "\\uninstall.exe"); process.StartInfo.Arguments = " /S"; process.Start(); process.WaitForExit(); } if (InstalledSoftware.NameContain2("teamviewer", "msi")) { Process process = new Process(); process.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory() + "\\TeamViewer"; process.StartInfo.FileName = "msiexec.exe"; process.StartInfo.Arguments = " /x \"" + Directory.GetCurrentDirectory() + "\\TeamViewer\\" + TeamViewer.GetMSIPackegeName() + "\" /norestart /qn"; process.Start(); process.WaitForExit(); } } catch (Exception exc) { MessageBox.Show("Стандартное сообщение таково: "); MessageBox.Show(exc.ToString()); MessageBox.Show("Свойство StackTrace: " + exc.StackTrace); MessageBox.Show("Свойство Message: " + exc.Message); MessageBox.Show("Свойство TargetSite: " + exc.TargetSite); } }
static public void Uninstall(int version) { try { if (InstalledSoftware.NameContain("teamviewer", "msi")) { Process process = new Process(); if (version == 9) { try { Microsoft.Win32.RegistryKey registryKey64 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\TeamViewer\Version9"); RegistryKey registryKey32 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\TeamViewer\Version9"); if (!OS.Is64Bit()) { process.StartInfo.WorkingDirectory = Registry.GetValue(registryKey32.Name, "InstallationDirectory", "NOT FOUND").ToString(); process.StartInfo.FileName = string.Format(Registry.GetValue(registryKey32.Name, "InstallationDirectory", "NOT FOUND").ToString() + "\\uninstall.exe"); } else { process.StartInfo.WorkingDirectory = Registry.GetValue(registryKey64.Name, "InstallationDirectory", "NOT FOUND").ToString(); process.StartInfo.FileName = string.Format(Registry.GetValue(registryKey32.Name, "InstallationDirectory", "NOT FOUND").ToString() + "\\uninstall.exe"); } } catch (System.Exception) { tvistallpath = "notinstalled"; } } else { process.StartInfo.WorkingDirectory = TeamViewer.Path; process.StartInfo.FileName = string.Format(TeamViewer.Path + "\\uninstall.exe"); } process.StartInfo.Arguments = " /S"; process.Start(); process.WaitForExit(); } if (InstalledSoftware.NameContain2("teamviewer", "msi")) { Process process = new Process(); process.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory() + "\\TeamViewer"; process.StartInfo.FileName = "msiexec.exe"; process.StartInfo.Arguments = " /x \"" + Directory.GetCurrentDirectory() + "\\TeamViewer\\" + version + "\\TeamViewer_Host.msi\" /norestart /qn"; process.Start(); process.WaitForExit(); } } catch (Exception exc) { MessageBox.Show("Стандартное сообщение таково: "); MessageBox.Show(exc.ToString()); MessageBox.Show("Свойство StackTrace: " + exc.StackTrace); MessageBox.Show("Свойство Message: " + exc.Message); MessageBox.Show("Свойство TargetSite: " + exc.TargetSite); } }