private static ApplicationUninstallerEntry GetBasicInformation(RegistryKey uninstallerKey) { return(new ApplicationUninstallerEntry { RegistryPath = uninstallerKey.Name, RegistryKeyName = uninstallerKey.GetKeyName(), Comment = uninstallerKey.GetStringSafe(RegistryNameComment), RawDisplayName = uninstallerKey.GetStringSafe(RegistryNameDisplayName), DisplayVersion = ApplicationEntryTools.CleanupDisplayVersion(uninstallerKey.GetStringSafe(RegistryNameDisplayVersion)), ParentKeyName = uninstallerKey.GetStringSafe(RegistryNameParentKeyName), Publisher = uninstallerKey.GetStringSafe(RegistryNamePublisher), UninstallString = GetUninstallString(uninstallerKey), QuietUninstallString = GetQuietUninstallString(uninstallerKey), ModifyPath = uninstallerKey.GetStringSafe(RegistryNameModifyPath), InstallLocation = uninstallerKey.GetStringSafe(RegistryNameInstallLocation), InstallSource = uninstallerKey.GetStringSafe(RegistryNameInstallSource), SystemComponent = (int)uninstallerKey.GetValue(RegistryNameSystemComponent, 0) != 0, DisplayIcon = uninstallerKey.GetStringSafe(RegistryNameDisplayIcon) }); }
private static ApplicationUninstallerEntry GetOneDrive() { var result = new ApplicationUninstallerEntry(); // Check if installed try { using (var key = RegistryTools.OpenRegistryKey(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\OneDrive", false)) { result.RegistryPath = key.Name; result.RegistryKeyName = key.GetKeyName(); result.InstallLocation = key.GetValue("CurrentVersionPath") as string; if (result.InstallLocation == null || !Directory.Exists(result.InstallLocation)) { return(null); } result.DisplayIcon = key.GetValue("OneDriveTrigger") as string; result.DisplayVersion = ApplicationEntryTools.CleanupDisplayVersion(key.GetValue("Version") as string); } } catch { return(null); } // Check if the uninstaller is available var systemRoot = WindowsTools.GetEnvironmentPath(CSIDL.CSIDL_WINDOWS); var uninstallPath = Path.Combine(systemRoot, @"System32\OneDriveSetup.exe"); if (!File.Exists(uninstallPath)) { uninstallPath = Path.Combine(systemRoot, @"SysWOW64\OneDriveSetup.exe"); if (!File.Exists(uninstallPath)) { uninstallPath = null; } } if (uninstallPath != null) { result.IsValid = true; result.UninstallString = $"\"{uninstallPath}\" /uninstall"; result.QuietUninstallString = result.UninstallString; if (!File.Exists(result.DisplayIcon)) { result.DisplayIcon = uninstallPath; } } result.AboutUrl = @"https://onedrive.live.com/"; result.RawDisplayName = "OneDrive"; result.Publisher = "Microsoft Corporation"; result.EstimatedSize = FileSize.FromKilobytes(1024 * 90); result.Is64Bit = MachineType.X86; result.IsRegistered = true; result.UninstallerKind = UninstallerType.Unknown; result.InstallDate = Directory.GetCreationTime(result.InstallLocation); if (!string.IsNullOrEmpty(result.DisplayIcon)) { result.IconBitmap = UninstallToolsGlobalConfig.TryExtractAssociatedIcon(result.DisplayIcon); } return(result); }
public IList <ApplicationUninstallerEntry> GetUninstallerEntries(ListGenerationProgress.ListGenerationCallback progressCallback) { var results = new List <ApplicationUninstallerEntry>(); if (!ChocoIsAvailable) { return(results); } var result = StartProcessAndReadOutput(ChocoFullFilename, @"list -lo -nocolor --detail"); if (string.IsNullOrEmpty(result)) { return(results); } var re = new System.Text.RegularExpressions.Regex(@"\n\w.+\r\n Title:"); var match = re.Match(result); if (!match.Success) { return(results); } var begin = match.Index + 1; while (true) { match = match.NextMatch(); if (!match.Success) { break; } var end = match.Index + 1; var info = result.Substring(begin, end - begin); int i = info.IndexOf(' '), j = info.IndexOf("\r\n"); var appName = new { name = info.Substring(0, i), version = info.Substring(i + 1, j - i - 1) }; var kvps = ExtractPackageInformation(info); if (kvps.Count == 0) { continue; } var entry = new ApplicationUninstallerEntry(); AddInfo(entry, kvps, "Title", (e, s) => e.RawDisplayName = s); entry.DisplayVersion = ApplicationEntryTools.CleanupDisplayVersion(appName.version); entry.RatingId = "Choco " + appName.name; entry.UninstallerKind = UninstallerType.Chocolatey; AddInfo(entry, kvps, "Summary", (e, s) => e.Comment = s); if (string.IsNullOrEmpty(entry.Comment)) { AddInfo(entry, kvps, "Description", (e, s) => e.Comment = s); if (string.IsNullOrEmpty(entry.Comment)) { AddInfo(entry, kvps, "Tags", (e, s) => e.Comment = s); } } AddInfo(entry, kvps, "Documentation", (e, s) => e.AboutUrl = s); if (string.IsNullOrEmpty(entry.AboutUrl)) { AddInfo(entry, kvps, "Software Site", (e, s) => e.AboutUrl = s); if (string.IsNullOrEmpty(entry.AboutUrl)) { AddInfo(entry, kvps, "Chocolatey Package Source", (e, s) => e.AboutUrl = s); } } var psc = new ProcessStartCommand(ChocoFullFilename, $"uninstall {appName.name} -y -r"); entry.UninstallString = psc.ToString(); if (entry.RawDisplayName == "Chocolatey") { entry.InstallLocation = GetChocoInstallLocation(); } // Prevent chocolatey from trying to run the original uninstaller (it's deleted by now), only remove the package psc.Arguments += " -n --skipautouninstaller"; var junk = new Junk.Containers.RunProcessJunk(entry, null, psc, Localisation.ChocolateyFactory_UninstallInChocolateyJunkName); junk.Confidence.Add(Junk.Confidence.ConfidenceRecords.ExplicitConnection); junk.Confidence.Add(4); entry.AdditionalJunk.Add(junk); results.Add(entry); begin = end; } return(results); }
private static IEnumerable <ApplicationUninstallerEntry> GetUpdates() { if (!HelperIsAvailable) { yield break; } var output = FactoryTools.StartHelperAndReadOutput(HelperPath, "list"); if (string.IsNullOrEmpty(output) || output.Trim().StartsWith("Error", StringComparison.OrdinalIgnoreCase)) { yield break; } foreach (var group in FactoryTools.ExtractAppDataSetsFromHelperOutput(output)) { var entry = new ApplicationUninstallerEntry { UninstallerKind = UninstallerType.WindowsUpdate, IsUpdate = true, Publisher = "Microsoft Corporation" }; foreach (var valuePair in group) { switch (valuePair.Key) { case "UpdateID": entry.RatingId = valuePair.Value; if (GuidTools.TryExtractGuid(valuePair.Value, out var result)) { entry.BundleProviderKey = result; } break; case "RevisionNumber": entry.DisplayVersion = ApplicationEntryTools.CleanupDisplayVersion(valuePair.Value); break; case "Title": entry.RawDisplayName = valuePair.Value; break; case "IsUninstallable": if (bool.TryParse(valuePair.Value, out var isUnins)) { entry.IsProtected = !isUnins; } break; case "SupportUrl": entry.AboutUrl = valuePair.Value; break; case "MinDownloadSize": if (long.TryParse(valuePair.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var size)) { entry.EstimatedSize = FileSize.FromBytes(size); } break; case "MaxDownloadSize": break; case "LastDeploymentChangeTime": if (DateTime.TryParse(valuePair.Value, CultureInfo.InvariantCulture, DateTimeStyles.None, out var date) && !DateTime.MinValue.Equals(date)) { entry.InstallDate = date; } break; default: Debug.Fail("Unknown label"); break; } } entry.UninstallString = $"\"{HelperPath}\" uninstall {entry.RatingId}"; entry.QuietUninstallString = entry.UninstallString; yield return(entry); } }
// TODO read the app manifests for more info, requires json parsing - var manifest = Path.Combine(installDir, "current\\manifest.json"); public IList <ApplicationUninstallerEntry> GetUninstallerEntries(ListGenerationProgress.ListGenerationCallback progressCallback) { var results = new List <ApplicationUninstallerEntry>(); if (!ScoopIsAvailable) { return(results); } // Make uninstaller for scoop itself var scoopEntry = new ApplicationUninstallerEntry { RawDisplayName = "Scoop", Comment = "Automated program installer", AboutUrl = "https://github.com/lukesampson/scoop", InstallLocation = _scoopUserPath }; // Make sure the global directory gets removed as well var junk = new FileSystemJunk(new DirectoryInfo(_scoopGlobalPath), scoopEntry, null); junk.Confidence.Add(ConfidenceRecords.ExplicitConnection); junk.Confidence.Add(4); scoopEntry.AdditionalJunk.Add(junk); scoopEntry.UninstallString = MakeScoopCommand("uninstall scoop").ToString(); scoopEntry.UninstallerKind = UninstallerType.PowerShell; results.Add(scoopEntry); // Make uninstallers for apps installed by scoop var result = RunScoopCommand("export"); if (string.IsNullOrEmpty(result)) { return(results); } var appEntries = result.Split(StringTools.NewLineChars.ToArray(), StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()); var exeSearcher = new AppExecutablesSearcher(); foreach (var str in appEntries) { // Format should be "$app (v:$ver) $global_display $bucket $arch" // app has no spaces, $global_display is *global*, bucket is inside [] brackets like [main] // version should always be there but the check errored out for some users, everything after version is optional string name; string version = null; bool isGlobal = false; var spaceIndex = str.IndexOf(" ", StringComparison.Ordinal); if (spaceIndex > 0) { name = str.Substring(0, spaceIndex); var startIndex = str.IndexOf("(v:", StringComparison.Ordinal); if (startIndex > 0) { var verEndIndex = str.IndexOf(')', startIndex); version = str.Substring(Math.Min(startIndex + 3, str.Length - 1), Math.Max(verEndIndex - startIndex - 3, 0)); if (version.Length == 0) { version = null; } } isGlobal = str.Substring(spaceIndex).Contains("*global*"); } else { name = str; } var entry = new ApplicationUninstallerEntry { RawDisplayName = name, DisplayVersion = ApplicationEntryTools.CleanupDisplayVersion(version), RatingId = "Scoop " + name }; var installDir = Path.Combine(isGlobal ? _scoopGlobalPath : _scoopUserPath, "apps\\" + name); if (Directory.Exists(installDir)) { // Avoid looking for executables in old versions entry.InstallLocation = Path.Combine(installDir, "current"); exeSearcher.AddMissingInformation(entry); entry.InstallLocation = installDir; } entry.UninstallerKind = UninstallerType.PowerShell; entry.UninstallString = MakeScoopCommand("uninstall " + name + (isGlobal ? " --global" : "")).ToString(); results.Add(entry); } return(results); }
public IList <ApplicationUninstallerEntry> GetUninstallerEntries(ListGenerationProgress.ListGenerationCallback progressCallback) { var results = new List <ApplicationUninstallerEntry>(); if (!HelperAvailable) { return(results); } var output = FactoryTools.StartHelperAndReadOutput(HelperPath, "/query"); if (string.IsNullOrEmpty(output)) { return(results); } foreach (var data in FactoryTools.ExtractAppDataSetsFromHelperOutput(output)) { if (!data.ContainsKey("CanonicalName")) { continue; } var name = data["CanonicalName"]; if (string.IsNullOrEmpty(name)) { continue; } var uninstallStr = $"\"{HelperPath}\" /uninstall {name}"; var entry = new ApplicationUninstallerEntry { RatingId = name, //RegistryKeyName = name, UninstallString = uninstallStr, QuietUninstallString = uninstallStr, IsValid = true, UninstallerKind = UninstallerType.Oculus, InstallLocation = data["InstallLocation"], DisplayVersion = ApplicationEntryTools.CleanupDisplayVersion(data["Version"]), IsProtected = "true".Equals(data["IsCore"], StringComparison.OrdinalIgnoreCase), }; var executable = data["LaunchFile"]; if (File.Exists(executable)) { ExecutableAttributeExtractor.FillInformationFromFileAttribs(entry, executable, true); entry.DisplayIcon = executable; } if (Directory.Exists(entry.InstallLocation)) { entry.InstallDate = Directory.GetCreationTime(entry.InstallLocation); } if (string.IsNullOrEmpty(entry.RawDisplayName)) { entry.RawDisplayName = name.Replace('-', ' ').ToTitleCase(); } results.Add(entry); } return(results); }