diff --git a/package/AgentWindowsManaged/Actions/AgentActions.cs b/package/AgentWindowsManaged/Actions/AgentActions.cs index 1845e4031..407b8bebf 100644 --- a/package/AgentWindowsManaged/Actions/AgentActions.cs +++ b/package/AgentWindowsManaged/Actions/AgentActions.cs @@ -194,6 +194,17 @@ internal static class AgentActions Impersonate = false, }; + private static readonly ManagedAction launchDesktopApp = new( + CustomActions.LaunchDesktopApp, + Return.ignore, + When.After, Step.InstallFinalize, + Condition.NOT_Installed & new Condition("(UILevel >= 3 OR WIXSHARP_MANAGED_UI_HANDLE <> \"\")"), + Sequence.InstallExecuteSequence) + { + Execute = Execute.immediate, + Impersonate = true, + }; + /// /// Start the installed DevolutionsAgent service /// @@ -215,7 +226,7 @@ internal static class AgentActions /// This was necessary in the old Wayk installer to reread configurations that may have been updated /// by the installer. It's usefulness os questionable with Devolutions Agent. /// - private static readonly ElevatedManagedAction restartAgent= new( + private static readonly ElevatedManagedAction restartAgent = new( CustomActions.RestartAgent, Return.ignore, When.After, Step.StartServices, @@ -330,6 +341,7 @@ private static string UseProperties(IEnumerable properties) cleanAgentConfigIfNeededRollback, shutdownDesktopApp, startAgentIfNeeded, + launchDesktopApp, restartAgent, rollbackConfig, }; diff --git a/package/AgentWindowsManaged/Actions/CustomActions.cs b/package/AgentWindowsManaged/Actions/CustomActions.cs index 5dff8d2d3..10d3c4185 100644 --- a/package/AgentWindowsManaged/Actions/CustomActions.cs +++ b/package/AgentWindowsManaged/Actions/CustomActions.cs @@ -219,6 +219,45 @@ public static ActionResult GetInstalledNetFx45Version(Session session) return ActionResult.Success; } + [CustomAction] + public static ActionResult LaunchDesktopApp(Session session) + { + try + { + string installDir = session.Property(AgentProperties.InstallDir); + + if (string.IsNullOrEmpty(installDir)) + { + session.Log("skipping launch of desktop application due to empty install dir"); + return ActionResult.Success; + } + + string path = Path.Combine(installDir, Includes.DESKTOP_DIRECTORY_NAME, Includes.DESKTOP_EXECUTABLE_NAME); + + if (!File.Exists(path)) + { + session.Log($"skipping launch of desktop application due to missing executable at {path}"); + return ActionResult.Success; + } + + ProcessStartInfo startInfo = new ProcessStartInfo(path) + { + WorkingDirectory = Path.Combine(installDir, Includes.DESKTOP_DIRECTORY_NAME), + UseShellExecute = true, + }; + + Process.Start(startInfo); + + return ActionResult.Success; + } + catch (Exception e) + { + session.Log($"unexpected error launching desktop application {e}"); + return ActionResult.Failure; + } + + } + static ActionResult ToggleAgentFeature(Session session, string feature, bool enable) { string path = Path.Combine(ProgramDataDirectory, "agent.json"); diff --git a/package/AgentWindowsManaged/Program.cs b/package/AgentWindowsManaged/Program.cs index f6fc3e15e..7c92230cd 100644 --- a/package/AgentWindowsManaged/Program.cs +++ b/package/AgentWindowsManaged/Program.cs @@ -287,7 +287,7 @@ static void Main() }, Dirs = new[] { - new Dir(Features.AGENT_FEATURE, "desktop", new Files(Features.AGENT_FEATURE, $"{DevolutionsDesktopAgentPath}\\*.*")), + new Dir(Features.AGENT_FEATURE, Includes.DESKTOP_DIRECTORY_NAME, new Files(Features.AGENT_FEATURE, $"{DevolutionsDesktopAgentPath}\\*.*")), new Dir(Features.PEDM_FEATURE, "ShellExt", new File(Features.PEDM_FEATURE, DevolutionsPedmShellExtDll), new File(Features.PEDM_FEATURE, DevolutionsPedmShellExtMsix)), @@ -310,7 +310,7 @@ static void Main() Win64 = project.Platform == Platform.x64, RegistryKeyAction = RegistryKeyAction.create, }, - new (RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", Includes.SERVICE_NAME, $"[{AgentProperties.InstallDir}]desktop\\{Includes.DESKTOP_EXECUTABLE_NAME}") + new (RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", Includes.SERVICE_NAME, $"[{AgentProperties.InstallDir}]{Includes.DESKTOP_DIRECTORY_NAME}\\{Includes.DESKTOP_EXECUTABLE_NAME}") { Win64 = project.Platform == Platform.x64, RegistryKeyAction = RegistryKeyAction.create, diff --git a/package/AgentWindowsManaged/Resources/Includes.cs b/package/AgentWindowsManaged/Resources/Includes.cs index df48caa66..5ee9e12ae 100644 --- a/package/AgentWindowsManaged/Resources/Includes.cs +++ b/package/AgentWindowsManaged/Resources/Includes.cs @@ -4,33 +4,35 @@ namespace DevolutionsAgent.Resources { internal static class Includes { - internal static string VENDOR_NAME = "Devolutions"; + internal static readonly string VENDOR_NAME = "Devolutions"; - internal static string PRODUCT_NAME = "Devolutions Agent"; + internal static readonly string PRODUCT_NAME = "Devolutions Agent"; - internal static string SHORT_NAME = "Agent"; + internal static readonly string SHORT_NAME = "Agent"; - internal static string SERVICE_NAME = "DevolutionsAgent"; + internal static readonly string SERVICE_NAME = "DevolutionsAgent"; - internal static string SERVICE_DISPLAY_NAME = "Devolutions Agent Service"; + internal static readonly string SERVICE_DISPLAY_NAME = "Devolutions Agent Service"; - internal static string SERVICE_DESCRIPTION = "Devolutions Agent Service"; + internal static readonly string SERVICE_DESCRIPTION = "Devolutions Agent Service"; - internal static string EXECUTABLE_NAME = "DevolutionsAgent.exe"; + internal static readonly string EXECUTABLE_NAME = "DevolutionsAgent.exe"; - internal static string DESKTOP_EXECUTABLE_NAME = "DevolutionsDesktopAgent.exe"; + internal static readonly string DESKTOP_DIRECTORY_NAME = "desktop"; - internal static string EMAIL_SUPPORT = "support@devolutions.net"; + internal static readonly string DESKTOP_EXECUTABLE_NAME = "DevolutionsDesktopAgent.exe"; - internal static string FORUM_SUPPORT = "forum.devolutions.net"; + internal static readonly string EMAIL_SUPPORT = "support@devolutions.net"; - internal static string SHELL_EXT_BINARY_NAME = "DevolutionsPedmShellExt.dll"; + internal static readonly string FORUM_SUPPORT = "forum.devolutions.net"; - internal static Guid SHELL_EXT_CSLID = new("0BA604FD-4A5A-4ABB-92B1-09AC5C3BF356"); + internal static readonly string SHELL_EXT_BINARY_NAME = "DevolutionsPedmShellExt.dll"; - internal static Guid UPGRADE_CODE = new("82318d3c-811f-4d5d-9a82-b7c31b076755"); + internal static readonly Guid SHELL_EXT_CSLID = new("0BA604FD-4A5A-4ABB-92B1-09AC5C3BF356"); - internal static string INFO_URL = "https://server.devolutions.net"; + internal static readonly Guid UPGRADE_CODE = new("82318d3c-811f-4d5d-9a82-b7c31b076755"); + + internal static readonly string INFO_URL = "https://server.devolutions.net"; /// /// SDDL string representing desired %programdata%\devolutions\agent ACL @@ -45,7 +47,7 @@ internal static class Includes /// BUILTIN\Administrators Allow FullControl /// BUILTIN\Users Allow ReadAndExecute, Synchronize /// - internal static string PROGRAM_DATA_SDDL = "O:SYG:SYD:PAI(A;OICI;FA;;;SY)(A;OICI;0x1201bf;;;LS)(A;OICI;FA;;;BA)(A;OICI;0x1200a9;;;BU)"; + internal static readonly string PROGRAM_DATA_SDDL = "O:SYG:SYD:PAI(A;OICI;FA;;;SY)(A;OICI;0x1201bf;;;LS)(A;OICI;FA;;;BA)(A;OICI;0x1200a9;;;BU)"; /// /// SDDL string representing desired %programdata%\devolutions\agent\pedm ACL @@ -57,6 +59,6 @@ internal static class Includes /// Access : /// NT AUTHORITY\SYSTEM Allow FullControl /// - internal static string PROGRAM_DATA_PEDM_SDDL = "O:SYG:SYD:(A;OICI;FA;;;SY)"; + internal static readonly string PROGRAM_DATA_PEDM_SDDL = "O:SYG:SYD:(A;OICI;FA;;;SY)"; } }