How to set permissions for directory

2019-07-28 10:54发布

问题:

I followed the SO link to add permission to a folder. However if I would like to set permission for directory, what can I do?

For example, in the link it has the following code:

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

How can I set permission for directory PHPFolder?

回答1:

Maybe try with a CreateFolder Element:

<Directory Id="INSTALLFOLDER" Name="Myfolder">
 <Component Feature="ProductFeature">
   <File Source="TestFile.exe" />
   <CreateFolder>
     <Permission User="Everyone" GenericAll="yes"/>
   </CreateFolder>
  </Component>
</Directory>

General Tip: Try to pillage github.com for snippets when you are stuck. Random Sample.


Further Links:

  • Several ways to apply permissions in WiX (mid page)
  • How to deny folder permission to Users with wix installer
  • System.UnauthorizedAccessException while running .exe under program files