Windows Services – Starting and Stopping with VB.Net
Over the past week I have been attempting to write a program that monitored a server, and restart the service as required. This is harder than it sounds. Only because searching the documentation takes so long. The answer…
Imports System.serviceprocess
Then we just need to use it. It is simlicity itself.
Dim junk As New ServiceController(“TabletService”)
If junk.Status = ServiceControllerStatus.Running Then
junk.Stop()
Else
junk.Start()
End If
Some error checking is needed of course, but that is that.