Process Monitoring - GetProcessesByName vs mutex

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi...

i sucessfully programmed a monitor wich is using GetProcessesByName to
monitor another process....and if the process is killed or closed, the
monitor restarts the process...

so far so good....but on some machines the GetProcessesByName method isn´t
working (because of the "process performance counter disabled...blabla")
this method isn´t very relyable ...

so i tried to programm a solution using the mutex threadding object...
but i have some problems with it.... it´s just working once :)

any suggestion or code samples?

kind regrads
 
AFAIK is is better to organize interprocess communication channel ( IPC ).
For example you can do that with sockets.

This method will work only if you have the source code of the process you
want to control...

In the other way you can use WMI, see System.Management namespace for more
details

ManagementObjectSearcher searcher = new ManagementObjectSearcher
("SELECT * FROM Win32_Process WHERE Name = MyProcess");
foreach (ManagementObject process in searcher.Get())
Console.WriteLine("Process = " + process["Name"]);
 
great!
it works...thank you a lot !!!

Vadym Stetsyak said:
AFAIK is is better to organize interprocess communication channel ( IPC ).
For example you can do that with sockets.

This method will work only if you have the source code of the process you
want to control...

In the other way you can use WMI, see System.Management namespace for more
details

ManagementObjectSearcher searcher = new ManagementObjectSearcher
("SELECT * FROM Win32_Process WHERE Name = MyProcess");
foreach (ManagementObject process in searcher.Get())
Console.WriteLine("Process = " + process["Name"]);

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com


Zabby said:
hi...

i sucessfully programmed a monitor wich is using GetProcessesByName to
monitor another process....and if the process is killed or closed, the
monitor restarts the process...

so far so good....but on some machines the GetProcessesByName method isn?t
working (because of the "process performance counter disabled...blabla")
this method isn?t very relyable ...

so i tried to programm a solution using the mutex threadding object...
but i have some problems with it.... it?s just working once :)

any suggestion or code samples?

kind regrads
 
Back
Top