mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 01:11:13 -06:00
SDA-4562 (Uninstall nsis installer registry entries) (#2151)
* SDA-4562 - Uninstall nsis installation if exists * SDA-4562 - Fix script issue * SDA-4562 - Fix script issue * SDA-4562 - Use QuietUninstallString and wait for exit * SDA-4562 - Change custom action execute settings * SDA-4562 - Change custom action execute settings * SDA-4562 - Change custom action execute settings * SDA-4562 - Use command instead of shellExecute * SDA-4562 - Use command instead of shellExecute
This commit is contained in:
parent
47bbaf9a13
commit
0e7e3b9d64
@ -170,6 +170,15 @@ class Script
|
|||||||
// Define the custom actions we want to run, and at what point of the installation we want to execute them.
|
// Define the custom actions we want to run, and at what point of the installation we want to execute them.
|
||||||
project.Actions = new WixSharp.Action[]
|
project.Actions = new WixSharp.Action[]
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// CleanNSISRegistryForCurrentUser
|
||||||
|
//
|
||||||
|
// This custom action is to remove any registry entries from HKEY_CURRENT_USER if exists
|
||||||
|
new ManagedAction(CustomActions.CleanNSISRegistryForCurrentUser, Return.check, When.Before, Step.LaunchConditions, Condition.NOT_Installed )
|
||||||
|
{
|
||||||
|
UsesProperties = "INSTALLDIR"
|
||||||
|
},
|
||||||
|
|
||||||
// InstallVariant
|
// InstallVariant
|
||||||
//
|
//
|
||||||
// We want to be able to display the POD URL dialog every time SDA starts after a reinstall, regardless of
|
// We want to be able to display the POD URL dialog every time SDA starts after a reinstall, regardless of
|
||||||
@ -518,6 +527,67 @@ public class CustomActions
|
|||||||
return ActionResult.Success;
|
return ActionResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CleanNSISRegistryForCurrentUser custom action
|
||||||
|
[CustomAction]
|
||||||
|
public static ActionResult CleanNSISRegistryForCurrentUser(Session session)
|
||||||
|
{
|
||||||
|
// Check if the INSTALLDIR starts with the per user installation path
|
||||||
|
if (session["INSTALLDIR"].StartsWith(System.Environment.ExpandEnvironmentVariables(@"%LOCALAPPDATA%\Programs\")))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
|
||||||
|
const string displayNameValue = "Symphony";
|
||||||
|
|
||||||
|
// Open the Uninstall key
|
||||||
|
using (var key = Registry.CurrentUser.OpenSubKey(uninstallKey))
|
||||||
|
{
|
||||||
|
if (key == null)
|
||||||
|
{
|
||||||
|
session.Log("Uninstall key not found.");
|
||||||
|
return ActionResult.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate through all subkeys
|
||||||
|
foreach (string subkeyName in key.GetSubKeyNames())
|
||||||
|
{
|
||||||
|
using (var subkey = key.OpenSubKey(subkeyName))
|
||||||
|
{
|
||||||
|
if (subkey == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the DisplayName value
|
||||||
|
string displayName = subkey.GetValue("DisplayName") as string;
|
||||||
|
if (displayName == displayNameValue)
|
||||||
|
{
|
||||||
|
// Get the UninstallString value
|
||||||
|
string uninstallString = subkey.GetValue("QuietUninstallString") as string;
|
||||||
|
if (!string.IsNullOrEmpty(uninstallString))
|
||||||
|
{
|
||||||
|
// Start the uninstallation process
|
||||||
|
var process = new System.Diagnostics.Process();
|
||||||
|
process.StartInfo.FileName = "cmd.exe";
|
||||||
|
process.StartInfo.Arguments = string.Format("/c \"{0}\"", uninstallString);
|
||||||
|
process.StartInfo.UseShellExecute = false;
|
||||||
|
process.Start();
|
||||||
|
process.WaitForExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
session.Log("Error executing CleanNSISRegistryForCurrentUser: " + e.ToString());
|
||||||
|
return ActionResult.Success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ActionResult.Success;
|
||||||
|
}
|
||||||
|
|
||||||
// StartAfterInstall custom action
|
// StartAfterInstall custom action
|
||||||
[CustomAction]
|
[CustomAction]
|
||||||
public static ActionResult StartAfterInstall(Session session)
|
public static ActionResult StartAfterInstall(Session session)
|
||||||
|
Loading…
Reference in New Issue
Block a user