Q:

Start a service from another computer

I have a project in which we would like to do the following :

Install a service that perform several tasks. this would be put on Computer A and B
Another computer C serves as a witness;
At start, only A is running because the work it performs cannot be duplicated;
Should A fail, then B must start. C should be the one that verify is one is running or not;
Sholud A return back up after a fail, then B still runs and A is on stand-by;
Should B then fail, C start A services,
And So On.

Is it possible, if so how ? Both A and B have a SQL server 2008 on them but this part is taken care of for us.
Thanks a lot.
EDIT : I tried stopping a service (that I know is running) and it dosn't seem to work :

    Dim path As ManagementPath = New ManagementPath
    path.Server = System.Environment.MachineName
    path.NamespacePath = "root\CIMV2"
    path.RelativePath = "Win32_service.Name='" + strServiceName + "'"
    Dim service As ManagementObject = New ManagementObject(path)
    Dim temp As ManagementBaseObject = service.InvokeMethod("StopService", Nothing, Nothing)

In this case, strServiceName is "CommunicationInterface" which is a service I recently add and started manually.
I am running under windows 7.

A:

Just set the services to not start automatically and then have the C computer start them as needed using the WMI class Win32_Service. You can also use this class to query if the services are running or not.
Look at the StartService and StopService methods as well as the State property.
Here's some sample code: Service Management in VB.NET

