0

I have a .NET application that installs a service using the custom installer/uninstaller.

This has been wrapped up into a Windows Installer, so that when it installs it registers the service, and when you deinstall it, it unregisters this service. But there are cases where the custom uninstaller can fail. (In my case, I had already manually uninstalled the service by calling installutil.)

Now, when I attempt to uninstall the product via the windows installer framework, the following error comes up:

Error 1001. An exception occurred 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.

This makes sense. Except that THEN, in spite of what the message said, the uninstallation is rolled back. (This problem is also described here).

I know that if I manually reinstalled the services the uninstalltion might work.

But I want to know if there's some way I can force this out of the list of installed products.


My current programmatic way of uninstalling this is to call

    ::MsiConfigureProduct(productCode.c_str(), INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT);

But this just has the same effect of uninstalling via the control panel, which fails.

What other approach can I take?

4

1 回答 1

2

This is why I tell people to not use Visual Studio Deployment Projects, InstallUtil custom actions and to only install on VM's and not on their own box.

So here's what you need to do:

Find the MSI that you used to install. Edit it with Orca and remove the custom actions from the InstallExecuteSequence (or put a no-op condition like GOTOHELL=666 on them ).

Run the command:

msiexec /i foo.msi REINSTALL=ALL REINSTALLMODE=vomus

This will 'recache' the MSI. Now uninstall the program using Add/Remove programs.

Now switch to a better tool that actually exposes the ServiceInstall table. Reinventing the wheel never ends well as you just discovered. Don't let it happen to your customer.

Finally, use the SC command to stop and delete the orphaned service.

于 2012-09-06T00:25:08.373 回答