是否可以以有限的权限安装到程序文件中?
我有一个将作为 MSI 包部署的应用程序(在 WiX 中编写)。
我正在决定是否根据安装程序的需要指定提升
或有限
权限。
除了位于 Program Files 下的默认安装位置之外,该应用程序不包含任何需要提升权限的内容。
现在的问题是:
如果我指定提升权限,那么在安装过程中 UAC 会提示用户输入管理员密码。这不是必需的,并且会阻止非管理员用户安装。
如果我指定有限权限,则会向用户显示一个对话框来选择安装位置,默认情况下
Program Files
。如果他们不更改安装位置(95% 的最终用户可能不会),则安装程序将失败,并显示一条消息,指示他们应联系管理员或以管理员身份运行应用程序。如果他们以管理员身份启动安装程序,那么他们可以毫无问题地安装到程序文件中 - 但大多数用户可能不知道如何以管理员身份启动安装程序。
我可以将默认安装位置设置为例如 C:\Company name\Program\,但这对我来说似乎是不标准的,并且大多数用户可能不会喜欢这样(他们可能习惯于安装到 Program Files 中)。
如何解决在有限用户帐户下安装应用程序的问题?
I have an application that will be deployed as MSI package (authored in WiX).
I am deciding whether to specify elevated
or limited
privileges as required for the installer.
The application does not include anything requiring elevated privileges besides the default install location, which is under Program Files.
Now the problem:
If I specify elevated privileges, then the user is prompted by UAC for administrator password during the installation. This is not required and prevents non-admin users from installing.
If I specify limited privileges, then the user is presented with a dialog to select install location with
Program Files
being default. In case they do not change the install location (95 % of end users probably won't), then the installer will fail with a message that they should contact the Administrator or run the application as administrator. If they launch the installer as Administrator then they can install into Program Files without problem - but most of the users won't probably know how to launch an installer as administrator.
I can potentially set the default install location to e.g. C:\Company name\Program\, but this seems nonstandard to me and majority of users will not probably like this (they are probably used to installing into Program Files).
How do you solve this problem with installing applications under limited user accounts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您建议的备用位置(直接位于 C 驱动器附近)可能也需要提升权限。在 Windows 7 之前,我建议使用早期自定义操作来更改有限安装的默认位置。将其限制在
Privileged
(或可能是AdminUser
)属性中,验证您是否需要为您的案例设置MSIUSEREALADMINDETECTION
,并使用类似 <代码>[LocalAppDataFolder]公司\产品。不幸的是,这种方法将导致所有用户都难以安装一个软件包,因为您必须预先提升,并且在有限的情况下,他们仍然可以选择需要提升的目标位置。它们必须预先提升,因为包裹必须标记为不可提升。如果您只能针对 Windows 7 及更高版本,则可以有条件地设置
MSIINSTALLPERUSER
来覆盖安装位置和提升要求,并改为按用户安装。在这种情况下,可能会询问用户是为所有用户安装(需要提升)还是仅为自己安装。可以将包标记为提升,并且设置MSIINSTALLPERUSER
将覆盖该设置并跳过 UAC 提示。The alternate location you propose, directly off of the C Drive, is likely to also require elevated privileges. Before Windows 7, I would suggest using an early custom action to change your default location for limited installations. Condition it off of the
Privileged
(or possiblyAdminUser
) property, verify whether you need to setMSIUSEREALADMINDETECTION
for your case, and use something like[LocalAppDataFolder]Company\Product
. Unfortunately this approach will result in a package that is difficult to install for all users as you must pre-elevate, and in the limited case they could still select a target location that requires elevation. They must pre-elevate because the package must be marked to not elevate.If you can target solely Windows 7 and later, you can conditionally set
MSIINSTALLPERUSER
to override the install location and the elevation requirement, and instead install per-user. In this scenario, the user could be asked whether to install for all users (requires elevation) or just for himself. The package can be marked for elevation, and settingMSIINSTALLPERUSER
will override that and skip the UAC prompt.您的软件以普通用户权限运行可能更重要 - 我认为您提到的这不是问题。
要求管理员权限来安装某些东西并没有什么错。
要么,用户自己会拥有详细信息,因为他们出于安全原因运行有限的帐户,要么软件将由其公司的 IT 部门安装。
It's probably more important that your software runs with normal user privileges - which I see you've mentioned isn't an issue.
There's nothing wrong in asking for admin rights to install something.
Either, the user will have the details themselves as they are running a limited account for safety reasons or the software will be installed by their company's IT department anyway.
以管理员身份运行命令提示符(cmd)。
然后使用msiexec命令来执行msi文件。
Run command prompt(cmd) as administrator.
Then use msiexec command to execute msi file.