问题
As I see it - WiX supports two kinds of CustomActions:
Deferred - The user running this action is (by default) elevated, but it is not the user who ran the install (for example, LocalSystem, or some user like that).
Immediate - The user running this action is (by default) not elevated - it's the user who ran the installer in the first place.
I need something quite in the middle - I want the elevated form (UAC) of the user who ran the installer.
The reason I need this is to access databases that can only be accessed by the user installing the package in its elevated form (LocalSystem is not accessible).
回答1:
This does not exist. There are only two possible contexts for custom actions to run in. One is the launching user (often via impersonation). The other is the elevated context of the Windows Installer service. On some machines (such as Windows XP, or machines with UAC disabled), or with elevating bootstraps, the launching user is an adminstrative user; you can check for this case with a combination of the MSIUSEREALADMINDETECTION and AdminUser properties. But in no case is there a third context.
来源:https://stackoverflow.com/questions/11736330/running-customaction-in-wix-as-elevated-user