diff --git a/src/Agent/AutopilotMonitor.Agent.V2.Core/Monitoring/Interop/ProcessOwnerLookup.cs b/src/Agent/AutopilotMonitor.Agent.V2.Core/Monitoring/Interop/ProcessOwnerLookup.cs index 35c6cb26..15d27edd 100644 --- a/src/Agent/AutopilotMonitor.Agent.V2.Core/Monitoring/Interop/ProcessOwnerLookup.cs +++ b/src/Agent/AutopilotMonitor.Agent.V2.Core/Monitoring/Interop/ProcessOwnerLookup.cs @@ -69,8 +69,8 @@ namespace AutopilotMonitor.Agent.V2.Core.Monitoring.Interop /// count the failure rate. A process that simply vanished between enumeration and query /// (zero rows) is NOT counted as an error. /// - /// Projects only ProcessId: GetOwner binds through the object's __PATH, - /// which WMI always returns regardless of the SELECT list, so this avoids materializing the + /// Projects only Handle + ProcessId: Handle is the key property WMI + /// needs for GetOwner method invocation, while still avoiding materializing the /// ~45 unused properties that SELECT * would. /// /// @@ -80,7 +80,7 @@ namespace AutopilotMonitor.Agent.V2.Core.Monitoring.Interop try { using (var searcher = new ManagementObjectSearcher( - $"SELECT ProcessId FROM Win32_Process WHERE ProcessId = {processId}")) + $"SELECT Handle, ProcessId FROM Win32_Process WHERE ProcessId = {processId}")) { foreach (ManagementObject obj in searcher.Get()) {