Set folder permissions to a folder sub folders and all files inside that

I have a scenario where multiple applications are installing in this same folder *C:\Programs\LMRK*

After installing my application now as a last step I need to give Users --> Full Control permissions to that *C:\Programs\LMKR* folder.

I tested running batch file from out side - NOT WORKED
I tested running this command icacls $myFolder /grant $myADGroup’:(OI)(CI)(F)’ - NOT WORKED

Please let me know what is the best way to give permissions to folders, sub folders and all files underneath it?


If you want the permissions to apply to all files and folders withing $myFolder then you should use the /t switch.

icacls reference

You can also change folder permissions using the get-acl/set-acl Powershell commands which I prefer over calling an external tool.

PowerShell – Editing permissions on a file or folder

Thanks for your reply.

I went through the reference links you provided and that was helpful. I decided to go with PowerShell way of setting the permissions.

Is there any PSADT specific function to set folder and file permissions?
If you can give couple of example scripts you created before to set permissions inside the PSADT that helps

Thank you

There aren’t any PSADT specific functions to set file and folder permissions. Here is an example from one of my scripts to set folder permissions:

##If it does not exist create the C:\Program Files\Your Program folder and allow all users.
#Create folder (will continue if folder exists)
$dirYourProgram = "$envProgramFiles\Your Program"
New-Folder -Path $dirYourProgram

#Add User permissions to Epic Games folder.
If (Test-Path $dirYourProgram) {
Write-Log -Message 'Updating ACL for C:\Program Files\Your Program...'
#Define the permission rule we want to add to the File/Folder. In this case add Users and AllowFullControl
$rule=new-object System.Security.AccessControl.FileSystemAccessRule ("BUILTIN\Users","FullControl","ContainerInherit,ObjectInherit","None","Allow")

#Get the existing ACL for the File/Folder we want to change permissions on.
$FolderACL = Get-ACL -Path $dirYourProgram

#Add the new permission rule to the existing File/Folder ACL

#Set the updated ACL on the File/Folder
Set-ACL -Path $dirYourProgram -AclObject $FolderACL

This example will create the folder if it doesnt already exist and add the Users group with full control. If there are existing files/folders in the program folder they will inherit the settings from the parent folder.