0

I can get the current start type of a service on a remote machine but I cannot change it. The ServiceController.StartType property is read-only.

Imports System.ServiceProcess

Dim myController As ServiceController
myController = New ServiceController With {
        .MachineName = "hostname",
        .ServiceName = "servicename"
        }

If .StartType.Equals(ServiceStartMode.Automatic) Then
        txtStartTypeSDM1.Text = "AUTOMATIC"
End If
myController.Close()

This guy managed to extend the ServiceController Class that enables changing the StartUpType but it only works locally. The new Class accepts the .MachineName property but I think its broken as it cannot find the specified ServiceName.

Ruben_PH
  • 1,692
  • 7
  • 25
  • 42
  • There is this [question/answer](https://stackoverflow.com/questions/1477618/how-do-i-change-a-windows-services-startup-type-in-net-post-install) that points to using the Win32 API – JayV Jun 28 '18 at 07:53
  • @JayV that is one of the question here that I looked into and it will only work if the service is on the local machine. – Ruben_PH Jun 28 '18 at 22:01

0 Answers0