/// <summary> /// Run the uninstaller on a new thread. /// </summary> internal void RunUninstaller(RunUninstallerOptions options) { lock (_operationLock) { if (Finished || IsRunning || CurrentStatus != UninstallStatus.Waiting) { return; } if (UninstallerEntry.IsRegistered && !UninstallerEntry.RegKeyStillExists()) { CurrentStatus = UninstallStatus.Completed; Finished = true; return; } if (UninstallerEntry.UninstallerKind == UninstallerType.Msiexec) { var uninstallString = IsSilentPossible && UninstallerEntry.QuietUninstallPossible ? UninstallerEntry.QuietUninstallString : UninstallerEntry.UninstallString; // Always reenumerate products in case any were uninstalled if (ApplicationEntryTools.PathPointsToMsiExec(uninstallString) && MsiTools.MsiEnumProducts().All(g => !g.Equals(UninstallerEntry.BundleProviderKey))) { CurrentStatus = UninstallStatus.Completed; Finished = true; return; } } CurrentStatus = UninstallStatus.Uninstalling; try { _worker = new Thread(UninstallThread) { Name = "RunBulkUninstall_Worker", IsBackground = false }; _worker.Start(options); } catch { CurrentStatus = UninstallStatus.Failed; Finished = true; throw; } } }
public void AddMissingInformation(ApplicationUninstallerEntry entry) { if (entry.IconBitmap != null) { return; } // Check for any specified icons if (!string.IsNullOrEmpty(entry.DisplayIcon) && !ApplicationEntryTools.PathPointsToMsiExec(entry.DisplayIcon)) { string resultFilename = null; if (File.Exists(entry.DisplayIcon)) { resultFilename = entry.DisplayIcon; } if (resultFilename == null) { try { var fName = ProcessTools.SeparateArgsFromCommand(entry.DisplayIcon).FileName; if (fName != null && File.Exists(fName)) { resultFilename = fName; } } catch { // Ignore error and try another method } } var icon = UninstallToolsGlobalConfig.TryExtractAssociatedIcon(resultFilename); if (icon != null) { entry.DisplayIcon = resultFilename; entry.IconBitmap = icon; } } }
public static UninstallerType GetUninstallerType(string uninstallString) { // Detect MSI / Windows installer based on the uninstall string // e.g. "C:\ProgramData\Package Cache\{33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}\vcredist_x86.exe" /uninstall if (ApplicationEntryTools.PathPointsToMsiExec(uninstallString) || uninstallString.ContainsAll( new[] { @"\Package Cache\{", @"}\", ".exe" }, StringComparison.OrdinalIgnoreCase)) { return(UninstallerType.Msiexec); } // Detect Sdbinst if (uninstallString.Contains("sdbinst", StringComparison.OrdinalIgnoreCase) && uninstallString.Contains(".sdb", StringComparison.OrdinalIgnoreCase)) { return(UninstallerType.SdbInst); } if (uninstallString.Contains(@"InstallShield Installation Information\{", StringComparison.OrdinalIgnoreCase)) { return(UninstallerType.InstallShield); } if (uninstallString.Contains("powershell.exe", StringComparison.OrdinalIgnoreCase) || uninstallString.Contains(".ps1", StringComparison.OrdinalIgnoreCase)) { return(UninstallerType.PowerShell); } if (ProcessStartCommand.TryParse(uninstallString, out var ps) && Path.IsPathRooted(ps.FileName) && File.Exists(ps.FileName)) { try { var fileName = Path.GetFileNameWithoutExtension(ps.FileName); // Detect Inno Setup if (fileName != null && InnoSetupFilenameRegex.IsMatch(fileName)) { // Check if Inno Setup Uninstall Log exists if (File.Exists(ps.FileName.Substring(0, ps.FileName.Length - 3) + "dat")) { return(UninstallerType.InnoSetup); } } // Detect NSIS Nullsoft.NSIS. Slow, but there's no other way than to scan the file using (var reader = new StreamReader(ps.FileName, Encoding.ASCII)) { string line; while ((line = reader.ReadLine()) != null) { if (line.Contains("Nullsoft", StringComparison.Ordinal)) { return(UninstallerType.Nsis); } } } /* Unused/unnecessary * if (result.Contains("InstallShield")) * return UninstallerType.InstallShield; * if (result.Contains("Inno.Setup") || result.Contains("Inno Setup")) * return UninstallerType.InnoSetup; * if(result.Contains(@"<description>Adobe Systems Incorporated Setup</description>")) * return UninstallerType.AdobeSetup; */ } catch (IOException) { } catch (UnauthorizedAccessException) { } catch (SecurityException) { } } return(UninstallerType.Unknown); }