"Failed to open registration key" WiX error is appearing when running Install after Uninstall

71 Views Asked by At

I'm creating an executable bundle installer using WiX Managed BA with custom UI, which installs one MSI. When the bundle is installed, I want to be able to run the setup.exe again, uninstall and then install again, but for some reason the subsequent installation doesn't seem to work and I'm seeing "Failed to open registration key" error in the log. Note that if I close the setup.exe after Uninstall and run it again, Install works just fine.

Here is an excerpt from the log when I run Install after Uninstall:

Planned package: TestAppSetup, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: Yes, uncache: No, dependency: Register
Plan complete, result: 0x0
Apply begin
Pausing automatic updates.
Paused automatic updates.
Creating a system restore point.
Could not create system restore point, error: 0x80070422. Continuing...
Error 0x80070002: Failed to open registration key.
Error 0x80070002: Failed to resume registration session.
Error 0x80070002: Failed to resume registration session in per-machine process.
Error 0x80070002: Failed to register bundle.
Apply complete, result: 0x80070002, restart: None, ba requested restart:  No

The strange issue is that if the bundle is not installed, I can start the setup.exe and run Install and Uninstall multiple times in a row and it works fine. The problem is occurring only when I:

  1. Run the setup.exe and install
  2. Close the setup.exe and run it again
  3. Perform Uninstall -> Install

I also tried calling Engine.Detect() in between Uninstall and Install, hoping it will force some kind of "refresh" under the hood, but it didn't work.

0

There are 0 best solutions below