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