Hi,
I created a Windows Service. I'd like the service to Stop when some error
happen.
Is there any way to do that without using the Services Controller? The
problem with it is that it seems to require Administrative rights and if I
use it from inside the same service then the Service account have to have
administrative rights.

Is there any way to make the service Stop it self?

Thanks a lot

LucasC

Re: How to Stop a Windows Service from inside by Metallikanz!

Metallikanz!
Sat Nov 12 07:05:29 CST 2005

An unhandled exception should surely stop the service.

using (ServiceController sc = new ServiceController(this.ServiceName)){

if (sc.CanStop)
sc.Stop();
}

Are you sure, doing the above doesn;t stop the service.

HTH, Metallikanz!


"LucasC" <msdn@rmya.com.ar> wrote in message
news:%23g04KEk5FHA.2560@TK2MSFTNGP12.phx.gbl...
> Hi,
> I created a Windows Service. I'd like the service to Stop when some error
> happen.
> Is there any way to do that without using the Services Controller? The
> problem with it is that it seems to require Administrative rights and if I
> use it from inside the same service then the Service account have to have
> administrative rights.
>
> Is there any way to make the service Stop it self?
>
> Thanks a lot
>
> LucasC
>
>