Ejemplo n.º 1
0
        private void UninstallJMMServer()
        {
            if (Utils.IsLinux)
            {
                return;                //This will be handled by the OS or user, as we cannot reliably learn what package management system they use.
            }
            try
            {
                // Check in registry if installed
                string jmmServerUninstallPath = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{898530ED-CFC7-4744-B2B8-A8D98A2FA06C}_is1", "UninstallString", null);

                if (!string.IsNullOrEmpty(jmmServerUninstallPath))
                {
                    // Ask if user wants to uninstall first
                    bool res = Utils.ShowYesNo(Resources.DuplicateInstallDetectedQuestion, Resources.DuplicateInstallDetected);

                    if (res)
                    {
                        try
                        {
                            ProcessStartInfo startInfo = new ProcessStartInfo {
                                FileName = jmmServerUninstallPath, Arguments = " /SILENT"
                            };
                            Process.Start(startInfo);

                            logger.Log(NLog.LogLevel.Info, "JMM Server successfully uninstalled");
                        }
                        catch
                        {
                            logger.Log(NLog.LogLevel.Error, "Error occured during uninstall of JMM Server");
                        }
                    }
                    else
                    {
                        logger.Log(NLog.LogLevel.Info, "User cancelled JMM Server uninstall");
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Log(NLog.LogLevel.Error, "Error occured during UninstallJMMServer: " + ex);
            }
        }