diff --git a/installer/win/WixSharpInstaller/Symphony.cs b/installer/win/WixSharpInstaller/Symphony.cs index f7daa091..4d35c767 100644 --- a/installer/win/WixSharpInstaller/Symphony.cs +++ b/installer/win/WixSharpInstaller/Symphony.cs @@ -211,6 +211,14 @@ class Script // versions of SDA, so we clean up all known variations, and ignore any missing ones. new ElevatedManagedAction(CustomActions.CleanRegistry, Return.ignore, When.After, Step.RemoveFiles, Condition.BeingUninstalled ), + + // CleanRegistryCurrentUser + // + // The registry keys stored under HKEY_CURRENT_USER can not be accessed through an ElevatedManagedAction, as + // elevated actions run as a different user (local system account rather than current user) so those keys + // are removed in this action. + new ManagedAction(CustomActions.CleanRegistryCurrentUser, Return.ignore, When.After, Step.RemoveFiles, Condition.BeingUninstalled ), + // Start Symphony after installation is complete new InstalledFileAction(new Id("symphony_exe"), "", Return.asyncNoWait, When.After, Step.InstallFinalize, Condition.NOT_BeingRemoved) }; @@ -392,15 +400,6 @@ public class CustomActions { // Remove registry keys added for auto-launch - using( var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true) ) - { - if (key != null) - { - key.DeleteValue("Symphony", false); - key.DeleteValue("com.symphony.electron-desktop", false); - key.DeleteValue("electron.app.Symphony", false); - } - } using( var key = Registry.Users.OpenSubKey(@"\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Run", true) ) { if (key != null) @@ -412,13 +411,6 @@ public class CustomActions // Remove registry keys added by protocol handlers - using( var key = Registry.CurrentUser.OpenSubKey(@"Software\Classes", true) ) - { - if (key != null) - { - key.DeleteSubKeyTree("symphony", false); - } - } using( var key = Registry.LocalMachine.OpenSubKey(@"Software\Classes", true) ) { if (key != null) @@ -441,4 +433,40 @@ public class CustomActions } return ActionResult.Success; } + + // CleanRegistryCurrentUser custom action + [CustomAction] + public static ActionResult CleanRegistryCurrentUser(Session session) + { + try + { + // Remove registry keys added for auto-launch + + using( var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true) ) + { + if (key != null) + { + key.DeleteValue("Symphony", false); + key.DeleteValue("com.symphony.electron-desktop", false); + key.DeleteValue("electron.app.Symphony", false); + } + } + + // Remove registry keys added by protocol handlers + + using( var key = Registry.CurrentUser.OpenSubKey(@"Software\Classes", true) ) + { + if (key != null) + { + key.DeleteSubKeyTree("symphony", false); + } + } + } + catch (System.Exception e) + { + session.Log("Error executing CleanRegistryCurrentUser: " + e.ToString() ); + return ActionResult.Success; + } + return ActionResult.Success; + } }