public override int GetHashCode() { return(DisplayName.GetHashCode() & DisplayVersion.GetHashCode() & UninstallString.to_string().GetHashCode() & KeyPath.GetHashCode()); }
public string GetPublicKeyToken() { var token = UninstallString.Split(',').First(s => s.Trim().StartsWith("PublicKeyToken=")).Substring(16); if (token.Length != 16) { throw new ArgumentException(); } return(token); }
public string GetInstallerName() { var token = UninstallString.Split(' ', ',').Select(s => s.Trim()).FirstOrDefault(s => s.EndsWith(".application")); if (null == token) { throw new ArgumentException(); } return(token); }
/// <summary> /// Is an application listed in ARP (Programs and Features)? /// </summary> /// <returns>true if the key should be listed as a program</returns> /// <remarks> /// http://community.spiceworks.com/how_to/show/2238-how-add-remove-programs-works /// </remarks> public bool is_in_programs_and_features() { return(!string.IsNullOrWhiteSpace(DisplayName) && !string.IsNullOrWhiteSpace(UninstallString.to_string()) && InstallerType != InstallerType.HotfixOrSecurityUpdate && InstallerType != InstallerType.ServicePack && string.IsNullOrWhiteSpace(ParentKeyName) && !NoRemove && !SystemComponent ); }
bool IEquatable <RegistryApplicationKey> .Equals(RegistryApplicationKey other) { if (ReferenceEquals(other, null)) { return(false); } return(DisplayName.to_string().is_equal_to(other.DisplayName) && DisplayVersion.is_equal_to(other.DisplayVersion) && UninstallString.to_string().is_equal_to(other.UninstallString.to_string()) && KeyPath.is_equal_to(other.KeyPath) ); }
public string GetApplicationName() { const string keyName = "ShArpMaintain "; var result = UninstallString.Split(',') .Select(s => s.Trim()) .First(s => s.StartsWith(keyName)) .Substring(keyName.Length); if (string.IsNullOrEmpty(result)) { throw new FormatException($"Application name not found in uninstall string {UninstallString}"); } return(result); }
public string GetPublicKeyToken() { const string keyName = "PublicKeyToken="; var result = UninstallString.Split(',') .Select(s => s.Trim()) .First(s => s.StartsWith(keyName)) .Substring(keyName.Length); if (result.Length != 16) { throw new FormatException($"Public Key Token not found in uninstall string {UninstallString}"); } return(result); }
// /// <summary> /// /// </summary> /// <param name="DisplayName"></param> /// <param name="DisplayVersion"></param> /// <param name="Arguments"></param> /// <returns></returns> public static List <string> Uninstall(string DisplayName, string DisplayVersion = "", string Arguments = "") { List <string> response = new List <string>(); foreach (DataRow row in Get().Rows) { if (row["Scope"].ToString() == "Machine" || row["Scope"].ToString() == Environment.UserName) { if (row["DisplayName"].ToString().ToLower().Contains(DisplayName.ToLower()) && row["DisplayVersion"].ToString().ToLower().Contains(DisplayVersion.ToLower())) { UninstallString uninstallString = new UninstallString(row["UninstallString"].ToString()); CMProcess.Start(uninstallString.FileName, (uninstallString.Arguments + " " + Arguments).Trim(), 60, true); response.Add(uninstallString.FileName + " " + (uninstallString.Arguments + " " + Arguments).Trim()); } } } return(response); }
private void ExecuteProcess(object sender, DoWorkEventArgs e) { OnOperationStatusChanged(new ProcessStatusEventArgs($"Starting uninstall of package {Name}", ComponentType)); Process p = new Process(); var startinfo = new ProcessStartInfo("msiexec.exe") { UseShellExecute = true, Arguments = UninstallString.Split(' ')[1], Verb = "runas" }; p.StartInfo = startinfo; try { Log.Debug($"Uninstall package with arguments: {startinfo.Arguments}"); p.Start(); p.WaitForExit(); if (!_removeDependency || SubComponent == null) { OnOperationStatusChanged(new ProcessStatusEventArgs($"Finished uninstall of package {Name}", ComponentType)); } else { OnOperationStatusChanged(new ProcessStatusEventArgs($"Starting uninstall of package {SubComponent.Name}", ComponentType)); startinfo.Arguments = SubComponent.UninstallString.Split(' ')[1]; p.StartInfo = startinfo; Log.Debug($"Uninstall package with arguments: {startinfo.Arguments}"); p.Start(); p.WaitForExit(); OnOperationStatusChanged(new ProcessStatusEventArgs($"Finished uninstall of package {SubComponent.Name}", ComponentType)); } p.Dispose(); } catch (Win32Exception ex) { Log.Error(ex, "Error while uninstalling", this); _cancelled = true; OnOperationStatusChanged(new ProcessStatusEventArgs(ex.Message, ComponentType)); p.Dispose(); } }