0
votes

I'm trying to execute my custom action in wix installer to remove a registry key which was written before in the InstallExecuteSequence before installing a software as follows:

 <InstallExecuteSequence>
      <Custom Action="RemoveExistingReristryKey" Sequence="150">NOT Installed</Custom>
 </InstallExecuteSequence>

When running .msi file, the function RemoveExistingReristryKey was invoked and registry key was deleted and I can see the log:

... Action ended 17:12:59: CostFinalize. Return value 1.

MSI (c) (90:54) [17:12:59:596]: Doing action: RemoveExistingReristryKey Action 17:12:59: RemoveExistingReristryKey. Action start 17:12:59: RemoveExistingReristryKey. MSI (c) (90:E4) [17:12:59:616]: Invoking remote custom action. DLL: C:\Users\CUONG~1.HUY\AppData\Local\Temp\MSIF947.tmp, Entrypoint: _RemoveExistingReristryKey@4 MSI (c) (90:8C) [17:12:59:616]: Cloaking enabled. MSI (c) (90:8C) [17:12:59:616]: Attempting to enable all disabled privileges before calling Install on Server MSI (c) (90:8C) [17:12:59:616]: Connected to service for CA interface. RemoveExistingReristryKey: Deleted registry key of the previous installation. Action ended 17:12:59: RemoveExistingReristryKey. Return value 1.

MSI (c) (90:54) [17:12:59:668]: Doing action: MaintenanceWelcomeDlg ...

However, the error which I want to fix still happens, however, if I remove this registry key manually, the error disappear.

I think maybe my custom action executes too late, so I try to edit by some options of custom action such as: before, after, sequence in the InstallExecuteSequence to execute this custom action immediately and before all of other actions but it's still not, it always executes after standard action "CostFinalize".

How can I execute my custom action immediately when running .msi file to remove registry key?

Thank you so much!

1
I'm a bit confused. It sounds like you're trying to delete a key that you're also writing to the registry during your install. Presumably you only need the registry key for part of the install and need it gone before the installation completes?Calum MacLeod
@CalumMacLeod I have an error as follow: While installing my software, if we cancel this process in a special case (cancel when extracting dialog appears), we are not able to re-install this software, because there is a registry key created before in SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products... If I remove this registry key manually, I can re-install my software normally, so I want to make a custom action in wix to remove this registry before installing, however, it seems that my custom action executes too late, so I cannot re-install my software.Cuong Huynh
Therefore, I want to execute my custom action immediately before all of other action of wix.Cuong Huynh

1 Answers

1
votes

I'm confused as to what you're trying to do, but, to me, it sounds like you're essentially trying to manage when your custom actions happen -- you have two of them and they are happening in the wrong order.

I have two pieces of advice: if you really want one custom action to happen before the other, schedule the first one in the InstallUISequence and the second in the InstallExecuteSequence. The InstallUISequence happens before the InstallExecuteSequence.

The second is to really look at when your custom actions are happening using ORCA. Open your .msi file using ORCA, then go to the InstallExecuteSequence table, then click on the Sequence column to sort by "when the action happens".

Here's an example from an MSI that I have: enter image description here

In this example I have two custom actions (circled) that I must have one-after-the-other. In order to do that, I did something along these lines:

<InstallExecuteSequence>
     <Custom Action="SetCustomAction_EncryptKey"
             After="InstallInitialize"/>
     <Custom Action="CustomAction_EncryptKey"
             After="SetCustomAction_EncryptKey"/>
</InstallExecuteSequence>

This guarantees that one happens right after the other. With that said, I could've done this, too, to make sure that the second one happened not necessarily the next action, but one of the actions after the first:

<InstallUISequence>
     <Custom Action="SetCustomAction_EncryptKey"
             Before="CostFinalize"/>
</InstallUISequence>
<InstallExecuteSequence>
     <Custom Action="CustomAction_EncryptKey"
             Before="CostFinalize"/>
</InstallExecuteSequence>

In any case, I've found ORCA to be a tool that demystified the entire "when to schedule custom actions".