创建新用户并将其添加到管理员时出现权限错误 [英] Getting privilege error while creating a new user and adding it to the administrators
问题描述
我使用 WiX 3.8 制作了一个安装项目,我想在其中创建一个新用户并将其添加到管理员组.但是每次我的设置到达那个点时,我都会因为权限不足而出错.这有点奇怪,因为我的用户是虚拟机的管理员,我在虚拟机上测试设置.我能做什么?
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?
WXS 文件中用于创建用户的代码如下:
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>
推荐答案
由于 UAC,即使用户是管理员,进程仍必须提升其权限.这使用户有机会在安全提示下拒绝提升权限.
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.
在 Package 元素中,确保您已设置InstallPrivileges="elevated"
.这应确保 Windows Installer 在安装过程中提示提升权限.
In the Package element, make sure you have set InstallPrivileges="elevated"
. This should ensure that Windows Installer prompts for elevated privileges during the installation.
这篇关于创建新用户并将其添加到管理员时出现权限错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!