add new user/permission to a folder via cmd or bat file?

Soldato
Joined
29 Jul 2003
Posts
7,671
hi

i need to add a new user 'everyone' to a folder with 'modify' permission enabled via cmd or a simple bat file?

the path to said folder is

c:\programdata\adobe\Slstore

thanks
 
Associate
Joined
2 Jul 2003
Posts
2,442
Can use PowerShell for this.
http://blogs.msdn.com/b/johan/archi...-editing-permissions-on-a-file-or-folder.aspx

This should do what you're after:
Code:
$Path = "C:\ProgramData\Adobe\Slstore"
$Acl = Get-Acl $Path

$AccessRule = New-Object system.security.accesscontrol.filesystemaccessrule("Everyone","Modify","Allow")
$Acl.SetAccessRule($AccessRule)

Set-Acl $Path $Acl

Basically it gets the access control list (list of permissions) for the folder into the $Acl object.
It then creates a new access rule which is added to the list.
The new list is then applied to the orginal folder so you should get everything you had before plus the new access rule.
 
Last edited:
Back
Top Bottom