how to get process description using WMI?

2019-09-06 16:40发布

问题:

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"]);
     }
}

回答1:

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.



回答2:

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.