[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

10/22/2009 at 09:45AM PDT, ID: 24835252 | Points: 500
[x]
Attachment Details

Windows Services BEFOREUninstall event?

Asked by kalliopi in C# Programming Language, .NET, Microsoft Visual C#.Net

Tags: Windows Services, installutil.exe, installutil, beforeinstall, beforeuninstall, event, ServiceController

I am trying to create a service that can be installed multiple times (different "instances").  So - first I figured out how to get to the serviceInstaller.Context.Parameters which let's me pass the service name in on the command line.  When installing the service, I can attach to the BeforeInstall event and rename the serviceInstaller.ServiceName property to reflect the instance name passed into the InstallUtil.exe on the command line - works GREAT.

Now - here's my question - for some BIZAR reason that I can NOT figure out - when I try to do the reverse (attaching to the BeforeUninstall event) so that I can uninstall the specific service instance that was previously installed, the InstallUtil.exe seems to behave in a completely unexpected way.  Specifically - it tries to uninstall the service with the default service name assigned at design time (which of course fails because the service was renamed on install) BEFORE firing my BeforeUninstall event handler??  WTF?  

I'm totally confused - shouldn't the BeforeUninstall event run BEFORE IT TRIES TO UNINSTALL THE SERVICE?  I added a windows message box to that event handler, and when I run:

InstallUtil /u MyService.exe

I can see it try (and fail) to uninstall the service and THEN my message box pops up?  What am I missing here?
[+][-]10/29/09 01:40 PM, ID: 25698011

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/20/09 07:03 PM, ID: 25876247

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74 - Hierarchy / EE_QW_EXPERT_20070906