Cannot uninstall Windows Service using MSI where ServiceName may be changed

Posted on 2009-04-19
Last Modified: 2013-11-14
I have created a Windows Service using vb in VS 2008 where I need to have multiple versions of the service running at the same time (refer attachment). This is optional.

I have changed the Installer to accept optional Context.Parameters for the Service Name and Display Name. If I use the command line installutil to install/uninstall everything works perfectly (e.g. installutil /NAME=myService /DISPLAYNAME="my Service" myService.exe).

I have also added a Setup Project as for some customers they won't need to have multiple instances and they aren't computer savvy so command lines are a bit too much for them. There are default values in the ProjectInstaller so that when running the MSI it uses the default parameters.

The problem occus if I try and uninstall via the MSI. The Service is uninstalled but I get the first error (below). Any further attempts to install via the MSI are met with 'Preparing to remove', the same error, then the Repair/Remove screen, then the second error below. The only way to run a clean install again is to delete the Registry Entry for the MSI in HKEY_CLASSES_ROOT\Installer\Products.

 I can use the installutil /u to successfully uninstall the service without specifying a NAME parameter (after using the MSI to install).

It appears that the problem is in the uninstall where no Context.Parameters are provided.

Can anyone help??

First error:

Error 1001. An exception occured while uninstalling. This exception will be ignored and the uninstall will continue. 

However, the application might not be fully uninstalled after the uninstall is complete. 

-> Service name contains invalid characters, is empty, or is too long (max lenght = 80).

Second error:

Error 1001. An exception occured while uninstalling. This exception will be ignored and the uninstall will continue. 

However, the application might not be fully uninstalled after the uninstall is complete. 

-> The specified service does not exist as an installed service.

Open in new window

Question by:thebigo
    LVL 40

    Accepted Solution

    This is too involved to give detailed answer - would require to fully reproduce the problem, which is quite nontrivial for this project.

    Just from the general perspective, I'd think that the way to solving this is in combining some diagnostic logging that you might put into the installer class with analyzing the log created by Installer itself. Find out if installer class is receiving the parameters during the uninstall. If it indeed does not, then probably next step is to see where they are coming from, and is that still the case during uninstall. Note that contrary to intuition, properties provided during the installation are not stored anywhere by Installer, and are not automatically available during the uninstall.

    All the above is of course quite blind shot - more thorough reply would require having the project and actually trying it.

    Author Closing Comment

    Thanks for your response. I eventually found I had left some code in the uninstall Custom Action :(.


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    One of the major drawbacks of deploying applications by GPO is the complete lack of any centralized reporting. After a normal deployment, there are two ways to find out if it was successful – by looking in the event log, and by looking in the log of…
    One of the most frequently asked questions on EE in the "Windows Installer" zone is how to eliminate self-triggered installation of some product.  The problem occurs when, suddenly, whenever a certain application is launched, or even when a folder i…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now