Click to See Complete Forum and Search --> : Process count


ajbharani
March 27th, 2008, 03:50 AM
Hello friends

I want to count the number of currently running processes with a particular name. I did like this

Console.WriteLine(Process.GetProcessesByName("svchost.exe").Length.ToString());

It returns 0.
But actually 6 such processes are running. What's the fault?

Regards
Bharani

sunny_sz
March 27th, 2008, 04:00 AM
Advise that you do follow below step:
1.) Search all process.
2.) Find the process with specified name
3.) count the number of step 2.)

that's all.

Good luck!

ajbharani
March 27th, 2008, 04:05 AM
Thanks a lot. It worked. Seems that .exe should not be specified. This worked!

Console.WriteLine(Process.GetProcessesByName("svchost").Length.ToString());


Regards
Bharani