467,136 Members | 1,275 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,136 developers. It's quick & easy.

DeleteService doesn't actually delete the service until the program is closed.

UJ
I have a program that will upgrade a service automatically. If the service
already exists, it will delete the service and then reinstall it through
code. To delete the service I'm using the DeleteService command which marks
the service as disabled but the service doesn't disappear until the program
shuts down. I've read on the web that it won't disappear until all
connections to the service manager have been closed. I close all my
connections yet it still is there until I close the program.

1. So I have two questions - does anybody know how to delete the service and
have it disappear immediately?
2. If I have a service and am upgrading it, do I need to remove it and
re-install it or can I just replace the executable?

TIA - Jeff.
Oct 18 '05 #1
  • viewed: 3206
Share:
4 Replies
1) This is probably an object lifetime issue. If you still have a
ServiceInstaller or ServiceController that references this service, you
will need to make sure that in has been cleaned up. You can acomplish
this by calling the Dispose() method which will explicitly invoke the
destructor and release associated resources.

2) You must remove and re-install. Services executables and
associated data are stored in a secure location in the registry.
Replacing the file on disk does not affect the service in the registry.

Oct 18 '05 #2
UJ
Thanks for your help. I finally found a spot where I wasn't closing the
service handle. Once I closed that, it works just as advertised.

J.

"Nick Hertl" <nh****@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
1) This is probably an object lifetime issue. If you still have a
ServiceInstaller or ServiceController that references this service, you
will need to make sure that in has been cleaned up. You can acomplish
this by calling the Dispose() method which will explicitly invoke the
destructor and release associated resources.

2) You must remove and re-install. Services executables and
associated data are stored in a secure location in the registry.
Replacing the file on disk does not affect the service in the registry.

Oct 18 '05 #3
With most services you can just replace the exe, of course it has to be
stopped to do this (whihc you can automate) - but you dont typically have to
remove the service entry.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"UJ" <fr**@nowhere.com> wrote in message
news:uX**************@TK2MSFTNGP14.phx.gbl...
I have a program that will upgrade a service automatically. If the service
already exists, it will delete the service and then reinstall it through
code. To delete the service I'm using the DeleteService command which marks
the service as disabled but the service doesn't disappear until the program
shuts down. I've read on the web that it won't disappear until all
connections to the service manager have been closed. I close all my
connections yet it still is there until I close the program.

1. So I have two questions - does anybody know how to delete the service
and have it disappear immediately?
2. If I have a service and am upgrading it, do I need to remove it and
re-install it or can I just replace the executable?

TIA - Jeff.

Oct 18 '05 #4
This is true if you know where the .NET ServiceInstaller tucked away
your executable. The trick is that if you replace the exe that you
used to install with InstallUtil, it will have no effect until you use
InstallUtil to uninstall and then reinstall your service. Of course if
you find where on the system it's putting your exe, you could just
replace that exe.

Oct 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Peter Abel | last post: by
3 posts views Thread by Matthias HALDIMANN | last post: by
149 posts views Thread by Christopher Benson-Manica | last post: by
4 posts views Thread by Robert Blackwell | last post: by
35 posts views Thread by mwelsh1118@gmail.com | last post: by
6 posts views Thread by SAL | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.