Windows installer using the NT AUTHORITY\SYSTEM instead of login user

时光总嘲笑我的痴心妄想 提交于 2019-12-02 14:01:31

问题


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 AUTHORITY\SYSTEM instead of using the login user. NT AUTHORITY\SYSTEMuser does not have permission to create a database.

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

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


回答1:


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

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.



来源:https://stackoverflow.com/questions/50838413/windows-installer-using-the-nt-authority-system-instead-of-login-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!