Service stopping itself

  • Thread starter Thread starter Jim in Arizona
  • Start date Start date
J

Jim in Arizona

I wrote a service and installed it. After thirty seconds, an event occurs
where it checks to see if another services is running and, if it is, start
another service. After this event, I want the service to shut itself down. I
tried the End ketword but that didn't look like it worked. This is a portion
of my code: The tmrChecker object is created in the OnStart method.

If svcMSSQLServer.Status = ServiceControllerStatus.Running Then
If Not svcMailPopper.Status = ServiceControllerStatus.Running
Then

svcMailPopper.Start()
End

End If
End If

Seems strait forward enough but I was refreshing services and the service
never stopped. It remained 'started'.
I'm sure I couldn't have itself stop by calling the Stop method of itself,
right? Like:

Dim svcThisService As New ServiceController("MyNewService")
svcThisService.Stop()

That wouldn't seem right.

TIA,
Jim
 
Apparently
Dim svcThisService As New ServiceController("MyNewService")
svcThisService.Stop()
Does Work.
 
Back
Top