Using WMI, how do I retrieve the list of running applications on a pc? If
you open up task manager and click on the applications tab, I am trying to
retrieve the task name and the status. I looked high and low in the WMI
documentation and unable to find a class that returns this info.
Any help is appreciated.
#region List all properties from WMI Query
// WMI Documentation
//
http://msdn.microsoft.com/library/de...re_classes.asp
string wmiQuery = "Select * from Win32_Process";
ManagementObjec tSearcher searcher = new ManagementObjec tSearcher(wmiQu ery);
Console.WriteLi ne("=========== =============== =============== =======");
Console.WriteLi ne(wmiQuery);
Console.WriteLi ne("=========== =============== =============== =======");
foreach (ManagementObje ct service in searcher.Get())
{
Console.WriteLi ne("=========== =============== =============== =======");
Console.WriteLi ne("SERVICE: " + service.ToStrin g());
Console.WriteLi ne("=========== =============== =============== =======");
foreach ( PropertyData s in service.Propert ies)
{
Console.WriteLi ne("Name: {0} Value: {1}", s.Name.ToString (),
service[s.Name.ToString ()]);
}
Console.ReadLin e();
}
Console.WriteLi ne("=========== =============== =============== =======");
Console.WriteLi ne("PRESS ENTER TO EXIT");
Console.WriteLi ne("=========== =============== =============== =======");
Console.ReadLin e();
#endregion