Hi Guys,
I'm after some assistance / guidance, I am trying to create an application to control windows services i.e stop / start across multiple servers simultaneously. There is probably more then 200 services across 20 servers.
I came across the System.ServiceProcess.ServiceController class and want to be able to pass multiple machines to the GetServices() method but can only pass one machine.
i.e
while
(dataset.read())
{
string ipaddress = dataset["ipaddress"].ToString()
ServiceController.GetServices(ipaddress);
foreach(ServiceController services in ipaddress);
{
services.Stop();
}
}
Is there any way around this or alternatively another class method to be able to do this?
The machines ip's and the services on the machine are from a SQL query dataset that I need to pass.
Not sure how else to access Windows services?
Thanks in advance
Loading
Kunal PandyaPosted Jun 1, 2009, 6:46 AM
I do want to retrieve the services as I want to be able to display them, but I would also need to use threads to restart all simultaneously.
The thing I am not sure about is how display and perfomr an action on the services without using the "GetServices()" method. If I looped through all machines from the resultset, would I need a new thread to create a new ServiceController for every machine?
Thanks.
vivek kulkarniPosted May 29, 2009, 11:32 AM
As per wat i understood you dont want to wait to access the service in the loop.
you can use threads to start looping for each server and have 20 threads.
You can use a timer control with a minimum time interval which will be again 20 threads for 20 servers.
i guess we also have a thread control.
However u will also have to consider other performance issues.
Thank you,