Home > Software engineering >  WIX installer UAC is called two times instead of one
WIX installer UAC is called two times instead of one

Time:11-29

i have got an WIX installer with following package information

<Package InstallerVersion="200"
         InstallScope="perMachine"
         Compressed="yes"
         Description="$(var.ProductName)"
         Manufacturer="$(var.ProductManufacturer)"
         InstallPrivileges="elevated"
         Platform="$(var.Platform)"/>  

This lead to this situation

enter image description here

After clicking "Installieren" UAC comes up and asks for administrator rights which is correct.

Within this installer i have to run a custom action for installing a explorer shellextension

<CustomAction Id="RegisterShellExtension"
         Directory="INSTALLDIR"
         ExeCommand='[INSTALLDIR]RegShell.exe --mode register --restartExplorer --path "[INSTALLDIR]$(var.ProductName)ShellExtension.dll"'
         Impersonate="no"
         Execute="deferred"
         Return="ignore">NOT VersionNT64</CustomAction>

<Custom Action="RegisterShellExtensionx" After="InstallFinalize">(NOT VersionNT64) AND (NOT Installed)</Custom>

In the manifest of RegShell.exe adminstrator rights are requested

<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />

This leads to the situation that the UAC asks for administrator rights again.

Is it possible that only one time UAC is raised instead of two times?

CodePudding user response:

WiX isn't calling UAC twice, your custom actions are. CA's have to be scheduled prior to InstallFinalize to run deferred. Do this with the no impersonation and they should already be running elevated as SYSTEM so therefore no UAC prompts.

BTW I should mention that these self registration custom actions are an antipattern as they can't be rolled back if they fail and can fail and break the installer. Normally we use registry entries to configure explorer.

For example, your condition is Not VersionNT64. You might want to add and Not REMOVE="ALL" otherwise the CA will try to fire during uninstall and fail. Oh wait, nevermind... you set Return="ignore" so if it ever does fail you'll sweep it under the rug and not know there is a problem.

https://learn.microsoft.com/en-us/windows/win32/shell/reg-shell-exts

Finally, I see you are using WiX v4 (Package element instead of Product element.) You should be aware that isn't a final GA and shouldn't be used for production installers.

  • Related