Windows 安装程序使用 NT AUTHORITYSYSTEM 而不是登录用户

Windows installer using the NT AUTHORITYSYSTEM instead of login user(Windows 安装程序使用 NT AUTHORITYSYSTEM 而不是登录用户)
本文介绍了Windows 安装程序使用 NT AUTHORITYSYSTEM 而不是登录用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Windows 安装程序,它在安装过程中创建一个数据库.安装应用程序 CREATE DATABASE 过程失败,因为 Windows 安装程序使用了错误的用户.它使用 NT AUTHORITYSYSTEM 而不是使用登录用户.NT AUTHORITYSYSTEM用户没有创建数据库的权限.

I have a windows installer, which is creating a database as a part of the installation process. While installing the application CREATE DATABASE process is failing because the windows installer using a wrong user. It is using NT AUTHORITYSYSTEM instead of using the login user. NT AUTHORITYSYSTEMuser does not have permission to create a database.

有没有办法强制安装程序使用登录用户?

Is there any way to force the installer to use the login user?

在 VS 2017 和 MS Visual Studio 2017 安装程序项目中使用 Windows 10 环境.

Using Windows 10 environment with VS 2017 and MS Visual Studio 2017 Installer Projects.

推荐答案

简短的回答是,您不能在作为 InstallAllUsers 设置的 Visual Studio 设置中执行此操作,因为所有 VS 安装程序生成的自定义操作都作为系统运行帐户.因此,您需要使用 Orca 等编辑工具更改 MSI 文件中的自定义操作设置.您会在 MSI 文件的 CustomAction 表中找到自定义操作,查看 Type 值(可能是类型 3074),然后关闭 msidbCustomActionTypeNoImpersonate 位,以便它以安装用户身份运行.

The short answer is that you can't do this in a Visual Studio setup that is an InstallAllUsers setup because the all VS installer generated custom actions run as the system account. Therefore you'd need to change the custom action settings in the MSI file with an editing tool such as Orca. You'd find the custom action in the CustomAction table in the MSI file, look at the Type values (it's probably a type 3074) and then turn off the msidbCustomActionTypeNoImpersonate bit so that it runs impersonated as the installing user.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa368069(v=vs.85).aspx

请注意,以安装用户身份运行有其自身的一系列问题,因为它与以交互式用户身份运行不同.未加载用户配置文件,因此与用户关联的对象(例如 HKCU、用户配置文件文件夹)非常不可靠.

Note that running impersonated as the installing user has its own set of issues because it is NOT the same as running as the interactive user. The user profile is not loaded, so objects associated with the user (such as HKCU, user profile folders) are very unreliable.

许多人在第一次启动应用程序时使用单独的程序填充数据库,以便它作为交互式用户正常运行,并且可以作为独立程序进行开发和调试.如果在安装过程中填充失败,您要么放弃安装并回滚,要么继续安装并最终得到一个空数据库,无论如何您可能需要一个程序来填充它.

Many people populate the databases with a separate programs the first time the application is launched so that it runs properly as the interactive user and can be developed and debugged as a standalone program. If the populate fails during the install you either give up the install and roll back, or you continue the install and end up with an empty database, for which you might need a program to populate it anyway.

这篇关于Windows 安装程序使用 NT AUTHORITYSYSTEM 而不是登录用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)