how to get process description using WMI?

2019-09-06 17:18发布

I'm using WMI query to get a list of all processes, but what i missing is process description! It appears like this when i use "Description" property!

Name : chrome.exe            Description : chrome.exe

but it should be

Name : chrome.exe            Description : Google Chrome

So what's the property name that return process description?

public void GetProcesses()
{ 
     ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * From Win32_Process");
     ManagementObjectCollection processList = searcher.Get();
     foreach (ManagementObject obj in processList)
     {
         Console.WriteLine("Name : {0}     Description : {1}",obj["Name"],obj["Description"]);
     }
}

2条回答
时光不老,我们不散
2楼-- · 2019-09-06 17:22

You have all the properties in the Win32_Process class documentation. Looks like you're out of luck, testing some processes on my machine using wbemtest, I don't see any property that suits you needs. It's possible that processes don't expose such information.

查看更多
可以哭但决不认输i
3楼-- · 2019-09-06 17:42

It is not WMI, but will work for processes on your local machine.

You may find a description of a process [sic.], actually it is the description of the executable, using GetVersionInfo. Than check the FileDescription and or ProductName properties.

Note however, that there is no guarantee that this information is available. Nevertheless it is probably your best bet. Other tools, like sysinternals process explorer, display that information as well.

查看更多
登录 后发表回答