Yes, that makes sense. Either way though I am left with an object of type
ManagementObjectSearcher or if I use a foreach an object of type
ManagementObject. So then I seem to be running into a problem testing if
these object are empty so that I can answer the question of whether the
process is running. I hope this makes sense. What type of statement can I
use to discern if the ManagementObjectSearcher is empty? I have tried using:
if (msProcessCcmExec != null)
but this returns an error about casting to bool, and I cannot manually cast
it to bool either. I appreciate your help.
"Nicholas Paldino [.NET/C# MVP]" wrote:
Primera,
If the program wasn't running, then it wouldn't be returned to you in
the query. It's only going to be returned to you if the process is actually
executing.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Primera" <Pr*****@discussions.microsoft.comwrote in message
news:0A**********************************@microsof t.com...
I am trying to determine if a particular process is running. I think I am
probably missing something obvious, but here is what I have so far...
ManagementObjectSearcher msProcessCcmExec = new
ManagementObjectSearcher("SELECT * FROM Win32_Process WHERE Name =
'CcmExec.exe'");
foreach (ManagementObject mo in msProcessCcmExec.Get())
{
logWrite.WriteLine(mo["Name"].ToString() + " is
running.");
}
This works fine if ccmexec.exe is running as it will write the line to my
log file. But what I really want to do is find out if ccmexec.exe is
running. So, how would that best be accomplished? I need to answer the
questions, "Is ccmexec.exe running?".
Thanks in advance for any help.