Bleile Datentechnik
Posts: 12
Joined: Mon Oct 11, 2010 3:13 pm

Run custom action with full privileges before upgade

Hi,

I need to run a custom action with full privileges (under the local system account) before "Install Execution State -> RemoveExistingProducts".
This custom action calls a function from a "Standard Dll" which will migrate the old software settings from an ini file to the new location within the windows registry.
To do this migration, the dll needs elevated user rights (it writes to HKEY_LOCAL_MASCHINE\Software\...).

After migration, the old software must be removed from the system (which is handled via Upgrades tab)

How can i achieve this - to get elevated rights?

Thanks in advance
Eusebiu
Posts: 4960
Joined: Wed Nov 14, 2012 2:04 pm

Re: Run custom action with full privileges before upgade

Hi,

In order to achieve this you can check the "Run as administrator" option from the "Install Parameters" page of your project. In this case, the package will be launched with administrator rights and all its custom actions will inherit those rights.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Bleile Datentechnik
Posts: 12
Joined: Mon Oct 11, 2010 3:13 pm

Re: Run custom action with full privileges before upgade

ahh of course, but it must be a msi setup rather than an exe setup.
Now it gets tricky?
Eusebiu
Posts: 4960
Joined: Wed Nov 14, 2012 2:04 pm

Re: Run custom action with full privileges before upgade

Hi,

Indeed, the "Run as administrator" option turns the package into an EXE, not MSI. Another workaround to achieve what you need is the following:
- create a simple MSI package that contains only that custom action after the "Add Resources" action group
- set the "deferred" with "no impersonation" options for the custom action
- uncheck the "Register product with Windows Installer" option from the "Product Details" page of the simple MSI's project
- check the "Limit to basic user interface (simple progress and error handling)" option in the "Install Parameters" page of the simple MSI
- add this MSI package as a feature-based prerequisite in your main product

Let me know if this helped.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Bleile Datentechnik
Posts: 12
Joined: Mon Oct 11, 2010 3:13 pm

Re: Run custom action with full privileges before upgade

Hi,

Nice trick! But it's also no solution for us, since we have a silent installation.
If u do a silent install, the feature-based prerequisites has a different execution order (they become installed right AFTER main installation and NOT before :evil: )

My current solution is:
1. Create a simple MSI which handles uninstallation of the old product via the upgrades tab
- uncheck the "Register product with Windows Installer" option from the "Product Details" page of the simple MSI's project
- check the "Limit to basic user interface (simple progress and error handling)" option in the "Install Parameters" page of the simple MSI
2. Add the "old software uninstaller.msi" as a "Chained package" to the Main MSI
3. Do the migration as custom action after "Install Execution State -> Preparing -> InstallInitialize" (which allow the execution under the local system account)

It works and i hope it's an acceptable solution.

Thank you very much!
Eusebiu
Posts: 4960
Joined: Wed Nov 14, 2012 2:04 pm

Re: Run custom action with full privileges before upgade

Hi,

Indeed, during a silent install the feature-based prerequisites are installed at the end of the main package's installation. I'm glad that you find a working solution.

Just let us know anytime you need help.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”