How to access an Service on a Remote PC

Peter

New member
Joined
May 30, 2007
Messages
1
Programming Experience
3-5
Hope this is the right place to ask.

I have a Sercive running on one PC. I need to be able to point this PC out from a VB .NET program running on another PC and with this VB program be able to start and stop the Service on the remote PC.

I have tested the program on with the Service running on the same PC as the VB program, and with this constellation it is possible to start and stop the service. But if I try and move the Service to a remote PC and the run the VB program again, I get an error.

From the PC with the VB program there are access to the remote PC, I am able to copy files between the two PC’s and I can look into a SQL database on the remote PC too.

I have looked around and it seems like there is other with the same problem, but I have not been able to find a solution any ware. Also the Microsoft documentation does not give any answer to this problem.

Peter

VB.NET:
Imports System
Imports System.ServiceProcess

Module Module_Services

    Public Sub StartService()

        Dim DataSource As String = "MachineName"
        Dim myServiceName As String = "Service"
        Dim sStatus As String
        Dim myController As ServiceController

        myController = New ServiceController
        myController.MachineName = DataSource
        myController.ServiceName = myServiceName

        myController.Refresh()
        sStatus = myController.Status.ToString

        Try
            myController.Start()
        Catch exp As Exception
            MsgBox("Could not start service")
        End Try

    End Sub

End Module
 
Last edited:
Back
Top