How to run a Custom Action inside an MSI created i

2019-02-23 15:41发布

问题:

I have an installer that needs to access the registry and copy and remove files using custom actions. In Windows XP the installer works just fine, but in Vista and 7, the installer shows an error because it cannot access a folder, but if I run the installer as administrator everything works.

So, I need the installer to be able to run the custom action as administrator even if the MSI wasnt run this way (need the installer to be run by regular users). I tried using an EXE at the beginning of my installation to modify the registry and allow the MSI to run normally but I dont think that's a very good solution.

PS. Bootstrapper is not an option due to client requirements :S All my custom Actions are deferred and impersonate="no"

Any ideas? Thank you

回答1:

Make sure that:

  • it's scheduled after InstallInitialize
  • "Execute" attribute is set to deferred
  • "Impersonate" attribute is set to no

Please note that deferred custom actions cannot access the installation session, so you cannot access installer properties directly.



回答2:

Your Custom Actions must be sequenced between InstallInitialize and InstallFinalize actions.

Do you get UAC prompt when you run the installer? If you perform a per-machine install, you would get UAC prompt when you click Install button in the wizard. If you don't get UAC prompt, then check ALLUSERS property is set to 2. See also Marking the Privileges for an MSI