From 84803c324eb8dee9356d2240a9716a4e72d74365 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Wed, 26 Aug 2020 15:34:06 -0700 Subject: [PATCH] Call SwitchToInputDesktop on startup. Additional logging. --- Agent/Services/ChatClientService.cs | 10 ++++++++++ Desktop.Win/Program.cs | 10 ++++++++-- Desktop.Win/Services/ShutdownServiceWin.cs | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Agent/Services/ChatClientService.cs b/Agent/Services/ChatClientService.cs index 23c737da..5400f0d6 100644 --- a/Agent/Services/ChatClientService.cs +++ b/Agent/Services/ChatClientService.cs @@ -60,6 +60,16 @@ namespace Remotely.Agent.Services var procID = await AppLauncher.LaunchChatService(orgName, senderConnectionID, hubConnection); + if (procID > 0) + { + Logger.Write($"Chat app started. Process ID: {procID}"); + } + else + { + Logger.Write($"Chat app did not start successfully."); + return; + } + var clientPipe = new NamedPipeClientStream(".", "Remotely_Chat" + senderConnectionID, PipeDirection.InOut, PipeOptions.Asynchronous); clientPipe.Connect(15000); if (!clientPipe.IsConnected) diff --git a/Desktop.Win/Program.cs b/Desktop.Win/Program.cs index cc03e6f0..3969c59d 100644 --- a/Desktop.Win/Program.cs +++ b/Desktop.Win/Program.cs @@ -48,19 +48,25 @@ namespace Remotely.Desktop.Win CasterSocket = Services.GetRequiredService(); Conductor.ProcessArgs(Environment.GetCommandLineArgs().SkipWhile(x => !x.StartsWith("-")).ToArray()); + Win32Interop.SwitchToInputDesktop(); + if (Conductor.Mode == Core.Enums.AppMode.Chat) { StartUiThread(null); - Services.GetRequiredService().StartChat(Conductor.RequesterID, Conductor.OrganizationName).Wait(); + _ = Task.Run(async () => + { + var chatService = Services.GetRequiredService(); + await chatService.StartChat(Conductor.RequesterID, Conductor.OrganizationName); + }); } else if (Conductor.Mode == Core.Enums.AppMode.Unattended) { StartUiThread(null); - Task.Run(StartScreenCasting); App.Current.Dispatcher.Invoke(() => { App.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; }); + _ = Task.Run(StartScreenCasting); } else { diff --git a/Desktop.Win/Services/ShutdownServiceWin.cs b/Desktop.Win/Services/ShutdownServiceWin.cs index 14fe2dd7..b01ea218 100644 --- a/Desktop.Win/Services/ShutdownServiceWin.cs +++ b/Desktop.Win/Services/ShutdownServiceWin.cs @@ -20,6 +20,7 @@ namespace Remotely.Desktop.Win.Services await casterSocket.DisconnectAllViewers(); System.Windows.Forms.Application.Exit(); App.Current.Shutdown(); + Environment.Exit(0); } } }