1

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?

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Kevin Lee
  • 71
  • 1
  • 8

1 Answers1

0

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:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • CreateFolder works. I also need to set Component Id and Guid in my case. Thanks much! – Kevin Lee Dec 11 '18 at 01:58
  • [Most component GUIDs can be auto-generated](https://stackoverflow.com/questions/24732761/syntax-for-guids-in-wix/24769965#24769965). Please be advised that it is generally better to use other permissioning constructs than the Permission element. See the list of ways in the link above. For simple permissions the Permission element should work I think. – Stein Åsmul Dec 11 '18 at 02:34
  • I try to use auto-generated GUID first. However it pops up error say Component using a Directory as KeyPath or containing ODBCDataSource child elements cannot use auto-generate GUID. And actually I am using util:PermissionEx instead of Permission. Thanks much for you advice, Stein. – Kevin Lee Dec 11 '18 at 02:43
  • Yes, that happens if you have no files in the component or a custom TARGETDIR pointing to D: drives or similar - and a few other cases. Glad it is working, best of luck with the rest. – Stein Åsmul Dec 11 '18 at 03:25