Nullsoft installer, howto make ProgramData subfolder writable
Asked Answered
T

2

8

ProgramData folder is the best place for storing your application's writeable files shared by all users. But when Nsis installer is run with admin privileges (which is required to write to Program Files), then folders and files created in ProgramData folder are read only for all users except admin. How to change that and have writeable files for all users inside ProgramData folder?

Tobiastobie answered 16/9, 2011 at 11:49 Comment(0)
T
8

I don't know if this behaviour is a feature or a bug, but I've found a workaround. The AccessControl plugin is needed (download and copy Nsis plugins folder). Inside "install" section of Nsis script put something like this:

; This is important to have $APPDATA variable
; point to ProgramData folder
; instead of current user's Roaming folder
SetShellVarContext all

; This sets us permissions
AccessControl::GrantOnFile "$APPDATA\Folder" "(S-1-5-32-545)" "FullAccess"
AccessControl::GrantOnFile "$APPDATA\Folder\*" "(S-1-5-32-545)" "FullAccess"

S-1-5-32-545 is equivalent to all users, so this code will grant full access to the specified folder and all files inside to all users.

Tobiastobie answered 19/9, 2011 at 12:44 Comment(1)
AccessControl::GrantOnFile "$APPDATA\Folder\*" "(S-1-5-32-545)" "FullAccess" line is unnecessary as all the folders and files inside the Folder will be given full access with the first line itself.Smalltime
C
2

or set via command line (Win7 only): ExecWait 'Icacls "$APPDATA\Folder" /grant Users:(OI)(CI)M'

Carltoncarly answered 14/12, 2011 at 22:49 Comment(1)
windows server 2003 and above actually :)Smalltime

© 2022 - 2024 — McMap. All rights reserved.