Exemple #1
0
        public static bool UninstallItpipes(string programInstallDirectoryOverride = null, bool forceUninstall = true)
        {
            if (doesProcessHaveAdminAccess() == false)
            {
                throw new PrivilegeNotHeldException("Uninstallation cannot proceed without administrator permissions. Please uninstall ITpipes through Control Panel.");
            }

            try {
                CloseITpipesIfRunning();
            }
            catch (Exception ex) {
                if (forceUninstall == false)
                {
                    throw;
                }
#if DEBUG
                Debugger.Break();
#endif
            }

            _itpipesInstallDir = getITpipesInstallationDirectory(programInstallDirectoryOverride);

            if (_itpipesInstallDir == null && forceUninstall == false)
            {
                throw new ProgramNotInstalledException();
            }

            if (Directory.Exists(_itpipesInstallDir) == false && forceUninstall == false)
            {
                throw new DirectoryNotFoundException("ITpipes installation directory does not exist.");
            }

            try {
                //Backup all ITpipes configurations - The path is taken from the default path for the config's backup model:
                UtilFunctions.CreateBackup();
                //CreateBackupOfAllConfigurations(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"ITpipes\ITpipesConfigBackup"));
            }
            catch (Exception) {
                if (forceUninstall == false)
                {
                    throw;
                }
            }

            try {
                SafelyDeleteLibraries();
            }
            catch (Exception) {
                if (forceUninstall == false)
                {
                    throw;
                }
            }
            try {
                SafelyDeleteDirectory(_itpipesInstallDir);
            }
            catch (Exception) {
                if (forceUninstall == false)
                {
                    throw;
                }
            }
            try {
                DeleteITpipesRegistryKeys();
            }
            catch (Exception) {
                if (forceUninstall == false)
                {
                    throw;
                }
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
            }

            try {
                DeleteProgramShortcuts();
            }
            catch (Exception) {
                if (forceUninstall == false)
                {
                    throw;
                }
#if DEBUG
                Debugger.Break();
#endif
            }


            return(true);
        }