Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用WMI查找挂起的windows进程,为什么是;“执行状态”;总是空的?_C#_Wmi - Fatal编程技术网

C# 使用WMI查找挂起的windows进程,为什么是;“执行状态”;总是空的?

C# 使用WMI查找挂起的windows进程,为什么是;“执行状态”;总是空的?,c#,wmi,C#,Wmi,我正在控制台程序中运行以下代码:- var query = string.Format("select * from Win32_Process"); var searcher = new ManagementObjectSearcher(query); var collection = searcher.Get(); foreach (ManagementObject o in collection)

我正在控制台程序中运行以下代码:-

 var query = string.Format("select * from Win32_Process");
            var searcher = new ManagementObjectSearcher(query);
            var collection = searcher.Get();
            foreach (ManagementObject o in collection)
            {         
                if(o["CommandLine"] == null) continue;
                if (o["ProcessId"] == null) continue;
                if( o["ExecutionState"] == null)continue;                
                var executionState =o["ExecutionState"].ToString();
                var commandLine = o["CommandLine"].ToString();
                var processId = o["ProcessId"];
                Console.WriteLine("{0}: {1} [{2}]", 
                   processId,
                   executionState,
                   commandLine);                
            }
但是,执行状态始终为空。有人知道为什么吗?我试着以管理员的身份运行

使用process explorer,我肯定有一个进程处于挂起状态:-


看起来像是
ExecutionState
没有实现,并且总是
null
。我不提,但要提