Windows Installer Error Uninstalling a Service (could not open key UNKNOWN)
While uninstalling a VS2010 setup project I'm developing which installs a service, I am receiving the following erro开发者_StackOverflow社区r (taken from the verbose MSI logging):
MSI (c) (60:90) [13:37:59:038]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg
Error 1402. Could not open key: UNKNOWN\Components\216B73E88467B322BBFF14C949E03D05\F1DB4DDE64042404E8863AB2CA9520DF. System error 5.
Verify that you have sufficient access to that key, or contact your support personnel.
MSI (s) (84:A4) [13:38:01:678]: User policy value 'DisableRollback' is 0
MSI (s) (84:A4) [13:38:01:678]: Machine policy value 'DisableRollback' is 0
Action ended 13:38:01: InstallExecute. Return value 3.
Note that this service is installed using a local machine account or a domain user account. It DOES NOT use the built-in account such as Network Service, Local System, or Local Service.
Using the Windows Installer Verbose Log Analyzer (wilogutl), it tells me that this section of code is the first error from the installer log. Furthermore, it tells me the possible solutions:
A standard action or custom action caused the failure.
Installer Version: 5.0.7601
Client Side Privilege Details: None
Server Side Privilege Details:
MSI (s) (84:A4) [13:37:55:306]: Product {EDD4BD1F-4046-4042-8E68-A32BAC5902FD} is managed. MSI (s) (84:A4) [13:37:55:306]: Running product '{EDD4BD1F-4046-4042-8E68-A32BAC5902FD}' with elevated privileges: Product is assigned.
I've tried running ProcMon to try and diagnose the problem but no luck. The installer seems to run no problem. The installer uses a custom action (C# InstallerClass) to install the service. The system cannot uninstall the service on my machine however.
Update 1: Here is the human-readable error from the logs:
(SERVER) MSI (s) (84:A4) [13:38:02:186]: Product: MyService -- Removal failed.
(UNKNOWN)
(SERVER) MSI (s) (84:A4) [13:38:02:186]: Windows Installer removed the product. Product Name: MyService. Product Version: 1.0.0. Product Language: 1033. Manufacturer: ManufacturerName. Removal success or error status: 1603.
(UNKNOWN)
(SERVER) MSI (s) (84:A4) [13:38:02:187]: Deferring clean up of packages/files, if any exist
(SERVER) MSI (s) (84:A4) [13:38:02:187]: MainEngineThread is returning 1603
And the error 1603 can be interpreted as the following (although this is not shown in the log):
The file [2][3] is being held in use by the following process: Name: [4], Id: [5], Window Title: '[6]'
Okay, I got some assistance from another developer and the problem turned out to be that the user account used to install the software was a Domain User account which had access to create registry keys but not the permissions to delete them during the uninstall.
This process left a lot of keys in the registry that cause problems on uninstall/reinstall.
The solution was to add myself as a local user account under Computer Management. Next I had to assign this user to the Users and Administrators group (just for good measure). Finally, I had to go into the registry and find all remnants of the software registry keys and forcibly delete them.
This was no easy feat because the process of deleting a key involved about six steps when you right-click and select Permissions on a key value:
- Granting full access to the Administrators account
- Granting full access to the Users account
- Click the advanced and add my domain user account
- Going to the Owner and "attempting" to add the Administrator as owner (w/Recursive children applied)
- Back to the users tab, grant full control to my domain user account
- Click OK and OK and then I can delete the key
精彩评论