From 2cfee523b1a080d593eb6d2ceb6d9d3ee56d3650 Mon Sep 17 00:00:00 2001 From: Oliver Kieselbach Date: Sat, 7 Mar 2026 08:18:19 +0100 Subject: [PATCH] fix for create user session process --- .../Monitoring/Core/UserSessionProcessLauncher.cs | 10 +++++++--- src/Agent/AutopilotMonitor.Agent/buildcounter.txt | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Agent/AutopilotMonitor.Agent.Core/Monitoring/Core/UserSessionProcessLauncher.cs b/src/Agent/AutopilotMonitor.Agent.Core/Monitoring/Core/UserSessionProcessLauncher.cs index bcc8aa09..b57af965 100644 --- a/src/Agent/AutopilotMonitor.Agent.Core/Monitoring/Core/UserSessionProcessLauncher.cs +++ b/src/Agent/AutopilotMonitor.Agent.Core/Monitoring/Core/UserSessionProcessLauncher.cs @@ -79,12 +79,15 @@ namespace AutopilotMonitor.Agent.Core.Monitoring.Core var si = new NativeMethods.STARTUPINFO(); si.cb = Marshal.SizeOf(si); si.lpDesktop = @"WinSta0\Default"; + si.dwFlags = NativeMethods.STARTF_USESHOWWINDOW; + si.wShowWindow = NativeMethods.SW_SHOW; - var creationFlags = NativeMethods.CREATE_NEW_CONSOLE; + uint creationFlags = 0; if (environment != IntPtr.Zero) creationFlags |= NativeMethods.CREATE_UNICODE_ENVIRONMENT; var commandLine = $"\"{exePath}\" {arguments}"; + var workingDirectory = System.IO.Path.GetDirectoryName(exePath); var procSa = new NativeMethods.SECURITY_ATTRIBUTES(); procSa.nLength = Marshal.SizeOf(procSa); @@ -100,7 +103,7 @@ namespace AutopilotMonitor.Agent.Core.Monitoring.Core false, // bInheritHandles creationFlags, environment, - null, // lpCurrentDirectory (inherit) + workingDirectory, ref si, out var pi)) { @@ -237,8 +240,9 @@ namespace AutopilotMonitor.Agent.Core.Monitoring.Core public const uint TOKEN_DUPLICATE = 0x0002; public const uint TOKEN_QUERY = 0x0008; public const uint MAXIMUM_ALLOWED = 0x02000000; - public const uint CREATE_NEW_CONSOLE = 0x00000010; public const uint CREATE_UNICODE_ENVIRONMENT = 0x00000400; + public const int STARTF_USESHOWWINDOW = 0x00000001; + public const short SW_SHOW = 5; public enum SECURITY_IMPERSONATION_LEVEL { diff --git a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt index f20bd4ef..26f42e64 100644 --- a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt +++ b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt @@ -1 +1 @@ -292 +294