Hi NG,

I'm writing a management tool for our software, that among other should be
able to install and uninstall some of our NT services.

The problem is that when I uninstall the services (using
ManagedInstallerClass.InstallHelper with the "/u" parameter) the services
are uninstalled, but they are still running until I close my management
application. This is a problem since I want to remove the service assemblies
as a part of the uninstallation.

I read the Knowledge Base-article 287516
(http://support.microsoft.com/default.aspx?scid=kb;en-us;287516), which
seems to be addressing my problem. It claims that all handles to the
services needs to be closed before the service can be uninstalled. Thats
fair enough, but eventhough all my ServiceControllers are Close()'d and
Dispose()'d the problem persists.

Is there a way to release all handles to a service allowing it to be
uninstalled at once?
Or is there another way to do this?

Thanks for your time,
Ricky

Re: Uninstalling a NT Service programmatically by Peter

Peter
Wed Dec 17 10:05:20 CST 2003

Stopping a service is an asynchronous process, you might use the
WaitForStatus to wait until the service is actually stopped.

Regards,

Peter

"Ricky K. Rasmussen" <ricky@ricky.dk> wrote in message
news:%23xVqazKxDHA.2116@TK2MSFTNGP11.phx.gbl...
> Hi NG,
>
> I'm writing a management tool for our software, that among other should be
> able to install and uninstall some of our NT services.
>
> The problem is that when I uninstall the services (using
> ManagedInstallerClass.InstallHelper with the "/u" parameter) the services
> are uninstalled, but they are still running until I close my management
> application. This is a problem since I want to remove the service
assemblies
> as a part of the uninstallation.
>
> I read the Knowledge Base-article 287516
> (http://support.microsoft.com/default.aspx?scid=kb;en-us;287516), which
> seems to be addressing my problem. It claims that all handles to the
> services needs to be closed before the service can be uninstalled. Thats
> fair enough, but eventhough all my ServiceControllers are Close()'d and
> Dispose()'d the problem persists.
>
> Is there a way to release all handles to a service allowing it to be
> uninstalled at once?
> Or is there another way to do this?
>
> Thanks for your time,
> Ricky
>
>



Re: Uninstalling a NT Service programmatically by Ricky

Ricky
Wed Dec 17 11:32:12 CST 2003

Peter,
Thanks for the reply, but it really doesn't answer my question.

I do use the WaitForStatus when stopping my Services and the services do get
stopped.

The problem is that I can't uninstall the services and then delete the
service assembles as a nice cleanup. The assemblies are still executing and
not uninstalled for real before I exit my application.

Thanks,
Ricky

"Peter Vervoorn" <newsuser@vervoorn.com> wrote in message
news:3fe07e11$0$41997$e4fe514c@dreader10.news.xs4all.nl...
> Stopping a service is an asynchronous process, you might use the
> WaitForStatus to wait until the service is actually stopped.
>
> Regards,
>
> Peter
>
> "Ricky K. Rasmussen" <ricky@ricky.dk> wrote in message
> news:%23xVqazKxDHA.2116@TK2MSFTNGP11.phx.gbl...
> > Hi NG,
> >
> > I'm writing a management tool for our software, that among other should
be
> > able to install and uninstall some of our NT services.
> >
> > The problem is that when I uninstall the services (using
> > ManagedInstallerClass.InstallHelper with the "/u" parameter) the
services
> > are uninstalled, but they are still running until I close my management
> > application. This is a problem since I want to remove the service
assemblies
> > as a part of the uninstallation.
> >
> > I read the Knowledge Base-article 287516
> > (http://support.microsoft.com/default.aspx?scid=kb;en-us;287516), which
> > seems to be addressing my problem. It claims that all handles to the
> > services needs to be closed before the service can be uninstalled. Thats
> > fair enough, but eventhough all my ServiceControllers are Close()'d and
> > Dispose()'d the problem persists.
> >
> > Is there a way to release all handles to a service allowing it to be
> > uninstalled at once?
> > Or is there another way to do this?
> >
> > Thanks for your time,
> > Ricky



Re: Uninstalling a NT Service programmatically by Steve

Steve
Wed Dec 17 12:06:43 CST 2003


If you stop the service, and the physical process remains
in the process viewer, then your service isn't cleaning
itself up properly.

I ran into this a while back. Turned out that I had a
thread that was in limbo due to a blocking socket call.

Services are especially unforgiving of resource leaks, as
their startup/shutdown is controlled by the SCM. You need
to be meticulous about thread management and cleanup.
Don't rely on the GC for anything.

>-----Original Message-----
>Peter,
>Thanks for the reply, but it really doesn't answer my
question.
>
>I do use the WaitForStatus when stopping my Services and
the services do get
>stopped.
>
>The problem is that I can't uninstall the services and
then delete the
>service assembles as a nice cleanup. The assemblies are
still executing and
>not uninstalled for real before I exit my application.
>
>Thanks,
>Ricky
>
>"Peter Vervoorn" <newsuser@vervoorn.com> wrote in message
>news:3fe07e11$0$41997
$e4fe514c@dreader10.news.xs4all.nl...
>> Stopping a service is an asynchronous process, you
might use the
>> WaitForStatus to wait until the service is actually
stopped.
>>
>> Regards,
>>
>> Peter
>>
>> "Ricky K. Rasmussen" <ricky@ricky.dk> wrote in message
>> news:%23xVqazKxDHA.2116@TK2MSFTNGP11.phx.gbl...
>> > Hi NG,
>> >
>> > I'm writing a management tool for our software, that
among other should
>be
>> > able to install and uninstall some of our NT
services.
>> >
>> > The problem is that when I uninstall the services
(using
>> > ManagedInstallerClass.InstallHelper with the "/u"
parameter) the
>services
>> > are uninstalled, but they are still running until I
close my management
>> > application. This is a problem since I want to
remove the service
>assemblies
>> > as a part of the uninstallation.
>> >
>> > I read the Knowledge Base-article 287516
>> > (http://support.microsoft.com/default.aspx?
scid=kb;en-us;287516), which
>> > seems to be addressing my problem. It claims that
all handles to the
>> > services needs to be closed before the service can
be uninstalled. Thats
>> > fair enough, but eventhough all my
ServiceControllers are Close()'d and
>> > Dispose()'d the problem persists.
>> >
>> > Is there a way to release all handles to a service
allowing it to be
>> > uninstalled at once?
>> > Or is there another way to do this?
>> >
>> > Thanks for your time,
>> > Ricky
>
>
>.
>

Re: Uninstalling a NT Service programmatically by Ricky

Ricky
Thu Dec 18 10:42:39 CST 2003

Thanks for your time Steve,
but as I pointed out, I had no problems stopping the services, my question
was concerning the uninstallation of these.

And I found a solution - or at least a way to solve this issue:
Instead of calling the ManagedInstallerClass.InstallHelper directly to
uninstall the services, I make the call through an external executable. I'm
not sure why this works but I guess it has something to do with the service
handles being released when the external executable exits.

- Ricky


"Steve Mentzer" <anonymous@discussions.microsoft.com> wrote in message
news:01cf01c3c4c8$86d03080$a301280a@phx.gbl...
>
> If you stop the service, and the physical process remains
> in the process viewer, then your service isn't cleaning
> itself up properly.
>
> I ran into this a while back. Turned out that I had a
> thread that was in limbo due to a blocking socket call.
>
> Services are especially unforgiving of resource leaks, as
> their startup/shutdown is controlled by the SCM. You need
> to be meticulous about thread management and cleanup.
> Don't rely on the GC for anything.
>
> >-----Original Message-----
> >Peter,
> >Thanks for the reply, but it really doesn't answer my
> question.
> >
> >I do use the WaitForStatus when stopping my Services and
> the services do get
> >stopped.
> >
> >The problem is that I can't uninstall the services and
> then delete the
> >service assembles as a nice cleanup. The assemblies are
> still executing and
> >not uninstalled for real before I exit my application.
> >
> >Thanks,
> >Ricky
> >
> >"Peter Vervoorn" <newsuser@vervoorn.com> wrote in message
> >news:3fe07e11$0$41997
> $e4fe514c@dreader10.news.xs4all.nl...
> >> Stopping a service is an asynchronous process, you
> might use the
> >> WaitForStatus to wait until the service is actually
> stopped.
> >>
> >> Regards,
> >>
> >> Peter
> >>
> >> "Ricky K. Rasmussen" <ricky@ricky.dk> wrote in message
> >> news:%23xVqazKxDHA.2116@TK2MSFTNGP11.phx.gbl...
> >> > Hi NG,
> >> >
> >> > I'm writing a management tool for our software, that
> among other should
> >be
> >> > able to install and uninstall some of our NT
> services.
> >> >
> >> > The problem is that when I uninstall the services
> (using
> >> > ManagedInstallerClass.InstallHelper with the "/u"
> parameter) the
> >services
> >> > are uninstalled, but they are still running until I
> close my management
> >> > application. This is a problem since I want to
> remove the service
> >assemblies
> >> > as a part of the uninstallation.
> >> >
> >> > I read the Knowledge Base-article 287516
> >> > (http://support.microsoft.com/default.aspx?
> scid=kb;en-us;287516), which
> >> > seems to be addressing my problem. It claims that
> all handles to the
> >> > services needs to be closed before the service can
> be uninstalled. Thats
> >> > fair enough, but eventhough all my
> ServiceControllers are Close()'d and
> >> > Dispose()'d the problem persists.
> >> >
> >> > Is there a way to release all handles to a service
> allowing it to be
> >> > uninstalled at once?
> >> > Or is there another way to do this?
> >> >
> >> > Thanks for your time,
> >> > Ricky
> >
> >
> >.
> >