简体   繁体   English

MSI安装程序文件/文件夹权限

[英]MSI Installer file/folder permissions

I'm trying to install a set of files within the programdata folder using basic MSI installer. 我正在尝试使用基本的MSI安装程序在programdata文件夹中安装一组文件。 As the content of the files are dynamic and generated during the installation process, I'm creating the files in C# code during installation. 由于文件内容是动态的并且在安装过程中生成,因此我在安装过程中使用C#代码创建文件。

The files are created in the appropriate folders, and everything is good, except the files permissions. 这些文件是在相应的文件夹中创建的,除文件权限外,一切都很好。 As I understand, files are supposed to inherit their permissions from the parent folder (if enabled), but in this case, this does not happen. 据我所知,文件应该从父文件夹(如果启用)继承其权限,但在这种情况下,这不会发生。 The files I create should be writable for regular users, and i do not wan't to set permissions explicitly for each file created. 我创建的文件对于普通用户应该是可写的,我不想为每个创建的文件显式设置权限。 Could the problem be that the installer runs with different permissions, and therefore the files does not inherit the permissions from their parent folders? 问题是安装程序是否以不同的权限运行,因此文件不会从其父文件夹继承权限?

Thanks in advance for any help. 在此先感谢您的帮助。

the installer runs with administrator access, which would allow it to change anything in program files. 安装程序以管理员访问权限运行,这将允许它更改程序文件中的任何内容。 A normal user would have read only access to the program files folder and the ProgramData/Common Application Data folder. 普通用户只能读取程序文件文件夹和ProgramData / Common Application Data文件夹。

MSI's lock permission table allows a setup program to change a folder's permission after creating in ProgramData/Common Application Data. MSI的锁定权限表允许安装程序在ProgramData / Common Application Data中创建后更改文件夹的权限。 Visual Studio's setup projects does not support MSI's lock permission table, so if you need the folder you created to be writable to normal users in a setup project you need to grant the right in a custom action using SetNamedSecurityInfo or modify the MSI database as a post build step. Visual Studio的安装项目不支持MSI的锁定权限表,因此如果您需要创建的文件夹可以在安装项目中向普通用户写入,则需要使用SetNamedSecurityInfo在自定义操作中授予权限,或者将MSI数据库修改为帖子建立步骤。 You can also find a MSI authoring software that can deal with MSI's lock permission table. 您还可以找到可以处理MSI锁定权限表的MSI创作软件。

我有类似的问题,我可以使用这里的例子来解决它。

I've had a similar problem here. 我在这里遇到过类似的问题。 The problem here is that msi was creating the files with user SYSTEM. 这里的问题是msi用用户SYSTEM创建文件。 And the application during runtime was using the logged user (that didn't have write permission to this file). 并且运行时期间的应用程序使用的是已记录的用户(该文件没有写入权限)。 What I did is create a new file (if not exists) during application initialization with the one created by the installer. 我所做的是在应用程序初始化期间使用安装程序创建的文件创建一个新文件(如果不存在)。 Then this file will have the write permission. 然后该文件将具有写入权限。 It's not a good practice but solved my problem. 这不是一个好习惯,但解决了我的问题。

如果使用自定义操作手动设置文件夹权限,并使用另一个自定义操作生成并安装文件,则问题可能是由执行顺序引起的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM