Window Services question

Is it possible to have the Windows Service stop itself in case of an error  Funny thing is that if there is an error OnStart then it throws an exception and stops. But if the error happens during the course of the run, it throws an exception to the EventLog and it keeps on running.
I do not want to manually stop it, I want the service to stop itself. Is that possible. End keyword works, but is there anything other than that

Thanks for your help.


Answer this question

Window Services question

  • Zeeshan Umar

    What you want to do is sent the signal to stop the service.  I think you just pass "net stop [your service name]" into the command prompt through System.Diagnostics.Process.
  • Window Services question