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

            var output = FactoryTools.StartProcessAndReadOutput(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.StartProcessAndReadOutput(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);
            }
        }
Example #2
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;
                }
            }
        }
        private static IEnumerable <ApplicationUninstallerEntry> GetUpdates()
        {
            if (!HelperIsAvailable)
            {
                yield break;
            }

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

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

            foreach (var group in ProcessInput(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;
                        Guid result;
                        if (GuidTools.TryExtractGuid(valuePair.Value, out result))
                        {
                            entry.BundleProviderKey = result;
                        }
                        break;

                    case "RevisionNumber":
                        entry.DisplayVersion = ApplicationEntryTools.CleanupDisplayVersion(valuePair.Value);
                        break;

                    case "Title":
                        entry.RawDisplayName = valuePair.Value;
                        break;

                    case "IsUninstallable":
                        bool isUnins;
                        if (bool.TryParse(valuePair.Value, out isUnins))
                        {
                            entry.IsValid = isUnins;
                        }
                        break;

                    case "SupportUrl":
                        entry.AboutUrl = valuePair.Value;
                        break;

                    case "MinDownloadSize":
                        long size;
                        if (long.TryParse(valuePair.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out size))
                        {
                            entry.EstimatedSize = FileSize.FromBytes(size);
                        }
                        break;

                    case "LastDeploymentChangeTime":
                        DateTime date;
                        if (DateTime.TryParse(valuePair.Value, CultureInfo.InvariantCulture, DateTimeStyles.None, out date) &&
                            !DateTime.MinValue.Equals(date))
                        {
                            entry.InstallDate = date;
                        }
                        break;
                    }
                }

                if (entry.IsValid)
                {
                    entry.UninstallString      = $"\"{HelperPath}\" uninstall {entry.RatingId}";
                    entry.QuietUninstallString = entry.UninstallString;
                }

                yield return(entry);
            }
        }
        public IEnumerable <ApplicationUninstallerEntry> GetUninstallerEntries(
            ListGenerationProgress.ListGenerationCallback progressCallback)
        {
            if (!WindowsTools.CheckNetFramework4Installed(true) || !File.Exists(StoreAppHelperPath))
            {
                yield break;
            }

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

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

            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;
                }

                yield return(result);
            }
        }