In a Windows Installer msi package, created with WIX, I want to execute a custom action (written in c#) that executes a powershell script file that is installed by the installer.
The script needs admin privileges to run correctly.
When I execute the custom action before InstallFinalize, then the execution fails because the script is not yet installed. When I execute the custom action after InstallFinalize, then the custom action does not have admin privileges.
How can I execute a custom action that executes an installed file with admin privileges?
You need to Execute the CustomAction deferred
to execute as part of the elevated installation transaction... and not impersonate. Read the CustomAction documentation.