David Brunelle
David Brunelle

Reputation: 6440

Start a service from another computer

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

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.

Upvotes: 2

Views: 2850

Answers (2)

Guido Domenici
Guido Domenici

Reputation: 5256

You should look into Windows Server 2008 Failover Clusters. From that page:

A failover cluster is a group of independent computers that work together to increase the availability of applications and services. The clustered servers (called nodes) are connected by physical cables and by software. If one of the cluster nodes fails, another node begins to provide service (a process known as failover). Users experience a minimum of disruptions in service.

Upvotes: 1

Hans Olsson
Hans Olsson

Reputation: 55009

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

Upvotes: 1

Related Questions