Exemple #1
0
        public IEnumerable <ApplicationUninstallerEntry> GetUninstallerEntries(
            ListGenerationProgress.ListGenerationCallback progressCallback)
        {
            if (ScriptHelperPath == null)
            {
                yield break;
            }

            var result = FactoryTools.StartHelperAndReadOutput(ScriptHelperPath, string.Empty);

            if (string.IsNullOrEmpty(result))
            {
                yield break;
            }

            var dataSets = FactoryTools.ExtractAppDataSetsFromHelperOutput(result);

            foreach (var dataSet in dataSets)
            {
                var entry = new ApplicationUninstallerEntry();

                // Automatically fill in any supplied static properties
                foreach (var entryProp in EntryProps)
                {
                    if (!dataSet.TryGetValue(entryProp.Name, out var item) || string.IsNullOrEmpty(item))
                    {
                        continue;
                    }

                    try
                    {
                        entryProp.SetValue(entry, item, null);
                    }
                    catch (SystemException ex)
                    {
                        Console.WriteLine(ex);
                    }
                }

                if (!entry.UninstallPossible && !entry.QuietUninstallPossible)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(entry.Publisher))
                {
                    entry.Publisher = "Script";
                }

                if (dataSet.TryGetValue("SystemIcon", out var icon) && !string.IsNullOrEmpty(icon))
                {
                    var iconObj = SystemIconProps
                                  .FirstOrDefault(p => p.Name.Equals(icon, StringComparison.OrdinalIgnoreCase))
                                  ?.GetValue(null, null) as Icon;
                    entry.IconBitmap = iconObj;
                }

                yield return(entry);
            }
        }
        private static IEnumerable <ApplicationUninstallerEntry> GetSteamApps()
        {
            if (!SteamHelperIsAvailable)
            {
                yield break;
            }

            var output = FactoryTools.StartHelperAndReadOutput(SteamHelperPath, "list");

            if (string.IsNullOrEmpty(output) || output.Contains("error", StringComparison.InvariantCultureIgnoreCase))
            {
                yield break;
            }

            foreach (var idString in output.SplitNewlines(StringSplitOptions.RemoveEmptyEntries))
            {
                if (!int.TryParse(idString, out var appId))
                {
                    continue;
                }

                output = FactoryTools.StartHelperAndReadOutput(SteamHelperPath, "info " + appId.ToString("G"));

                if (string.IsNullOrEmpty(output))
                {
                    continue;
                }

                var lines = output.SplitNewlines(StringSplitOptions.RemoveEmptyEntries).Select(x =>
                {
                    var o = x.Split(new[] { " - " }, StringSplitOptions.None);
                    return(new KeyValuePair <string, string>(o[0], o[1]));
                }).ToList();

                string GetValue(string fieldName)
                {
                    return(lines.Single(x => x.Key.Equals(fieldName, StringComparison.InvariantCultureIgnoreCase)).Value);
                }

                var entry = new ApplicationUninstallerEntry
                {
                    DisplayName     = GetValue("Name"),
                    UninstallString = GetValue("UninstallString"),
                    InstallLocation = GetValue("InstallDirectory"),
                    UninstallerKind = UninstallerType.Steam,
                    IsValid         = true,
                    IsOrphaned      = true,
                    RatingId        = "Steam App " + appId.ToString("G")
                };

                if (long.TryParse(GetValue("SizeOnDisk"), out var bytes))
                {
                    entry.EstimatedSize = FileSize.FromBytes(bytes);
                }

                yield return(entry);
            }
        }
Exemple #3
0
        public IEnumerable <ApplicationUninstallerEntry> GetUninstallerEntries(ListGenerationProgress.ListGenerationCallback progressCallback)
        {
            if (!HelperAvailable)
            {
                yield break;
            }

            var output = FactoryTools.StartProcessAndReadOutput(HelperPath, "/query");

            if (string.IsNullOrEmpty(output))
            {
                yield break;
            }

            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"],
                    InstallDate     = Directory.GetCreationTime(data["InstallLocation"]),
                    DisplayVersion  = data["Version"],
                    IsProtected     = "true".Equals(data["IsCore"], StringComparison.OrdinalIgnoreCase),
                };

                var executable = data["LaunchFile"];
                if (File.Exists(executable))
                {
                    ExecutableAttributeExtractor.FillInformationFromFileAttribs(entry, executable, true);
                }

                if (string.IsNullOrEmpty(entry.RawDisplayName))
                {
                    entry.RawDisplayName = name.Replace('-', ' ').ToTitleCase();
                }

                yield return(entry);
            }
        }
        private static void GetSteamInfo()
        {
            _steamHelperIsAvailable = false;

            if (File.Exists(SteamHelperPath) && WindowsTools.CheckNetFramework4Installed(true))
            {
                var output = FactoryTools.StartProcessAndReadOutput(SteamHelperPath, "steam");
                if (!string.IsNullOrEmpty(output) &&
                    !output.Contains("error", StringComparison.InvariantCultureIgnoreCase) &&
                    Directory.Exists(output = output.Trim().TrimEnd('\\', '/')))
                {
                    _steamHelperIsAvailable = true;
                    SteamLocation           = output;
                }
            }
        }
Exemple #5
0
        public static void GenerateMisingInformation(List <ApplicationUninstallerEntry> entries,
                                                     InfoAdderManager infoAdder, List <Guid> msiProducts, bool skipRunLast,
                                                     ListGenerationProgress.ListGenerationCallback progressCallback)
        {
            void WorkLogic(ApplicationUninstallerEntry entry, object state)
            {
                infoAdder.AddMissingInformation(entry, skipRunLast);
                if (msiProducts != null)
                {
                    entry.IsValid = FactoryTools.CheckIsValid(entry, msiProducts);
                }
            }

            var workSpreader = new ThreadedWorkSpreader <ApplicationUninstallerEntry, object>(MaxThreadsPerDrive,
                                                                                              WorkLogic, list => null, entry => entry.DisplayName ?? entry.RatingId ?? string.Empty);

            var cDrive       = new DirectoryInfo(Environment.SystemDirectory).Root;
            var dividedItems = SplitByPhysicalDrives(entries, entry =>
            {
                var loc = entry.InstallLocation ?? entry.UninstallerLocation;
                if (!string.IsNullOrEmpty(loc))
                {
                    try
                    {
                        return(new DirectoryInfo(loc));
                    }
                    catch (SystemException ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
                return(cDrive);
            });

            workSpreader.Start(dividedItems, progressCallback);
            workSpreader.Join();
        }
        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);
            }
        }
        public IList <ApplicationUninstallerEntry> GetUninstallerEntries(
            ListGenerationProgress.ListGenerationCallback progressCallback)
        {
            var results = new List <ApplicationUninstallerEntry>();

            if (StoreAppHelperPath == null)
            {
                return(results);
            }

            var output = FactoryTools.StartHelperAndReadOutput(StoreAppHelperPath, "/query");

            if (string.IsNullOrEmpty(output))
            {
                return(results);
            }

            var windowsPath = WindowsTools.GetEnvironmentPath(CSIDL.CSIDL_WINDOWS);

            foreach (var data in FactoryTools.ExtractAppDataSetsFromHelperOutput(output))
            {
                if (!data.ContainsKey("InstalledLocation") || !Directory.Exists(data["InstalledLocation"]))
                {
                    continue;
                }

                var fullName     = data["FullName"];
                var uninstallStr = $"\"{StoreAppHelperPath}\" /uninstall \"{fullName}\"";
                var isProtected  = data.ContainsKey("IsProtected") && Convert.ToBoolean(data["IsProtected"], CultureInfo.InvariantCulture);
                var result       = new ApplicationUninstallerEntry
                {
                    Comment              = fullName,
                    CacheIdOverride      = fullName,
                    RatingId             = fullName.Substring(0, fullName.IndexOf("_", StringComparison.Ordinal)),
                    UninstallString      = uninstallStr,
                    QuietUninstallString = uninstallStr,
                    RawDisplayName       = string.IsNullOrEmpty(data["DisplayName"]) ? fullName : data["DisplayName"],
                    Publisher            = data["PublisherDisplayName"],
                    IsValid              = true,
                    UninstallerKind      = UninstallerType.StoreApp,
                    InstallLocation      = data["InstalledLocation"],
                    InstallDate          = Directory.GetCreationTime(data["InstalledLocation"]),
                    IsProtected          = isProtected,
                    SystemComponent      = isProtected
                };

                if (File.Exists(data["Logo"]))
                {
                    try
                    {
                        result.DisplayIcon = data["Logo"];
                        result.IconBitmap  = DrawingTools.IconFromImage(new Bitmap(data["Logo"]));
                    }
                    catch
                    {
                        result.DisplayIcon = null;
                        result.IconBitmap  = null;
                    }
                }

                if (result.InstallLocation.StartsWith(windowsPath, StringComparison.InvariantCultureIgnoreCase))
                {
                    result.SystemComponent = true;
                    //result.IsProtected = true;
                }

                results.Add(result);
            }

            return(results);
        }