Question

Locked

Problem with ServiceController

By bonsai9552 ·
I'm using a ServiceController to try to start and stop a service on XP. Each time the form loads I can either stop or start the services, but not both. If I use the start button to start the service, the stop button won't work and vice versa.

Here's the code. Any insights would be much appreciated.

Private Sub btnStartService_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartService.Click

If (ServiceController1.Status.ToString <> "Running") Then
ServiceController1.Start()
End If

End Sub

Private Sub btnStopService_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStopService.Click

If ServiceController1.Status.ToString <> "Stopped" Then
ServiceController1.Stop()
End If

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Windows Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums