Wix: How to set permissions for folder and all sub folders

天涯浪子 提交于 2020-01-09 02:15:26

问题


I know how to set the permissions for a folder:

<DirectoryRef Id="ProgramFilesFolder">
  <Directory Id="PHPFolder" Name="PHP">
    <Component Id="PHP_comp" DiskId="1" Guid="*">
      <CreateFolder>
        <Permission User="Everyone" GenericAll="yes" />
      </CreateFolder>

However I need the permissions to be applied to all subfolders as well. Is this possible with out listing all the folders?


回答1:


First of all, I would recommend you using PermissionEx instead. It is a standard WiX extension and it has one really huge advantage over Permission - it doesn't overwrite, but modifies ACLs. And by default, it applies permissions to the folder and all its descendant files and folders, so you don't have to specify anything extra.

Hope this helps.




回答2:


I solved: different PermissionEx are defined in Wix and Util schema (Wix PermissionEx and Util Extension PermissionEx)

I used the Util version:

  • Add a reference to WixUtilExtension assembly
  • Add the UtilExtension namespace to the Wix tag:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  • Specify the Util PermissionEx version:
<CreateFolder Directory="DirectoryToManage">
    <util:PermissionEx User="Users" GenericAll="yes" />
</CreateFolder>



回答3:


<DirectoryRef Id="INSTALLFOLDER">
        <Component Id="INSTALLFOLDER_Permission" Guid="*">
            <CreateFolder>
                <util:PermissionEx User="Users" GenericAll="yes"/>
            </CreateFolder>
        </Component>
    </DirectoryRef>

The answer above is correct, and you will set the permissions to all the folders and files in this folder.

Please note: The CreateFolder tag should be in a component, and this component must be added to a Feature.

Also, you have to add this to the command line of the compiler and the linker:

-ext WixUIExtension -ext WixUtilExtension


来源:https://stackoverflow.com/questions/4272406/wix-how-to-set-permissions-for-folder-and-all-sub-folders

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