I have a made a setup-project with WiX 3.8 in which i want to create a new user and add it to the administrators group. But each time my setup comes to that point, i get an error because of insufficient privileges. That's a little bit curious, because my user is an administrator on the virtual machine, on which i test the setup. What can i do?
That's the code in the WXS-file for creating the user:
<util:Group Id="Administrators"
Name ="Administrators"
Domain="[ComputerName]" />
<Component Id ="CreateUserAccount"
Guid="AEE91491-99FA-40A9-AB47-1E9FC2DDEF2A"
Directory="TARGETDIR">
<util:User Id ="SQLUser"
Name="[MyUsername]"
Password="[MyPassword]"
UpdateIfExists="no"
CreateUser="yes"
PasswordNeverExpires="yes"
PasswordExpired="no"
RemoveOnUninstall="no"
Domain="[ComputerName]">
<util:GroupRef Id ="Administrators"/>
</util:User>
</Component>
Because of UAC, a process must still elevate its privileges even if the user is an administrator. This gives the user a chance to deny the elevation of privileges at the security prompt.
In the Package element, make sure you have set
InstallPrivileges="elevated"
. This should ensure that Windows Installer prompts for elevated privileges during the installation.