Monday, 1 August 2011

How to set file permissions in NSIS script

Use AccessControl plugin.
Download package, unpack it and place AccessControl.dll into "..\NSIS\Plugins".

The following code snippet from nsi script creates directory and sets Read, Execute and List folder contents rights for IUSR user on it. Additionally, it makes all objects within it to inherit its permissions.

!define TEST_DIR "C:\inetpub\wwwroot\Test"
...
Section "Create web directory" sec1
   CreateDirectory ${TEST_DIR }
   AccessControl::GrantOnFile ${TEST_DIR } "IUSR" "ListDirectory + GenericRead + GenericExecute"
   AccessControl::EnableFileInheritance ${TEST_DIR }
SectionEnd

No comments: