private static Guid GetGuid(RegistryKey uninstallerKey) { // Look for a GUID registry entry var tempGuidString = uninstallerKey.GetStringSafe(RegistryNameBundleProviderKey); if (GuidTools.GuidTryParse(tempGuidString, out var resultGuid)) { return(resultGuid); } if (GuidTools.TryExtractGuid(uninstallerKey.GetKeyName(), out resultGuid)) { return(resultGuid); } string uninstallString = GetUninstallString(uninstallerKey); // Look for a valid GUID in the path return(GuidTools.TryExtractGuid(uninstallString, out resultGuid) ? resultGuid : Guid.Empty); }
private static Guid GetGuid(RegistryKey uninstallerKey) { // Look for a GUID registry entry var tempGuidString = uninstallerKey.GetValue(ApplicationUninstallerEntry.RegistryNameBundleProviderKey) as string; Guid resultGuid; if (GuidTools.GuidTryParse(tempGuidString, out resultGuid)) { return(resultGuid); } if (GuidTools.TryExtractGuid(uninstallerKey.GetKeyName(), out resultGuid)) { return(resultGuid); } var uninstallString = uninstallerKey.GetValue(ApplicationUninstallerEntry.RegistryNameUninstallString) as string; // Look for a valid GUID in the path return(GuidTools.TryExtractGuid(uninstallString, out resultGuid) ? resultGuid : Guid.Empty); }
private static IEnumerable <ApplicationUninstallerEntry> GetUpdates() { if (!HelperIsAvailable) { yield break; } var output = SteamFactory.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 = 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); } }
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); } }