Пример #1
0
        private UninstallOlderSoftwareStatus RemoveProduct(string productCode, string olderOxigenInstallSource)
        {
            string installPath = null;
            UninstallOlderSoftwareStatus status = RunSupportFiles();

            _logger.WriteTimestampedMessage("Have support files run? UninstallOlderSoftwareStatus: " + status.ToString());

            if (_backgroundWorker != null)
            {
                _backgroundWorker.ReportProgress(5);
            }

            if (status != UninstallOlderSoftwareStatus.Success)
            {
                return(status);
            }

            object installPathObj = GenericRegistryAccess.GetRegistryValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Oxigen", "path");

            if (installPathObj != null)
            {
                installPath = (string)installPathObj;
                _logger.WriteTimestampedMessage(@"HKEY_LOCAL_MACHINE\SOFTWARE\Oxigen\path = " + installPath);
            }
            else
            {
                _logger.WriteTimestampedMessage(@"HKEY_LOCAL_MACHINE\SOFTWARE\Oxigen\path not found");
            }

            status = UninstallMSI(productCode);

            _logger.WriteTimestampedMessage("UninstallMSI return status: " + status);

            if (_backgroundWorker != null)
            {
                _backgroundWorker.ReportProgress(80);
            }

            _bSystemModified = true;

            if (status != UninstallOlderSoftwareStatus.Success)
            {
                return(status);
            }

            // delete install directory
            if (installPathObj != null && Directory.Exists(installPath))
            {
                _logger.WriteTimestampedMessage("Deleting directory " + installPath);

                try
                {
                    if (Directory.Exists(installPath))
                    {
                        Directory.Delete(installPath, true);
                    }
                }
                catch (Exception ex)
                {
                    _logger.WriteTimestampedMessage(ex.ToString());

                    return(UninstallOlderSoftwareStatus.ErrorDeletingBinaries);
                }
            }

            // delete temp install directory that Older Oxigen normally leaves
            if (olderOxigenInstallSource != null && Directory.Exists(olderOxigenInstallSource))
            {
                try
                {
                    if (Directory.Exists(olderOxigenInstallSource))
                    {
                        Directory.Delete(olderOxigenInstallSource, true);
                    }
                }
                catch (Exception ex)
                {
                    _logger.WriteTimestampedMessage(ex.ToString());

                    return(UninstallOlderSoftwareStatus.ErrorDeletingTempInstallFiles);
                }
            }

            GenericRegistryAccess.DeleteRegistryValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Oxigen", "path");
            GenericRegistryAccess.DeleteRegistryValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Oxigen", "path");

            if (_backgroundWorker != null)
            {
                _backgroundWorker.ReportProgress(100);
            }

            return(UninstallOlderSoftwareStatus.Success);
        }
Пример #2
0
        internal OldOxigenUninstallReturnStatus Uninstall()
        {
            string productCode = null;
            string olderOxigenInstallSource = null;

            UninstallOlderSoftwareStatus status = GetProductCode(ref productCode, ref olderOxigenInstallSource);

            _logger.WriteTimestampedMessage("Has product code been retrieved? UninstallOlderSoftwareStatus: " + status.ToString());

            if (status != UninstallOlderSoftwareStatus.Success)
            {
                return(new OldOxigenUninstallReturnStatus(status, _bSystemModified));
            }

            _logger.WriteTimestampedMessage("Existing product code found: " + productCode);

            status = RemoveProduct(productCode, olderOxigenInstallSource);

            return(new OldOxigenUninstallReturnStatus(status, _bSystemModified));
        }