4

How can I change permissions for the folder including subfolders?

4 Answers 4

7

If you don't want to do this from the GUI, you could use the command line program cacls using the /T option.

(or use icacls which is the new version of cacls).

If you want to use the GUI, right-click the folder, choose properties, then click the security tab. Click Advanced, then click Change Permissions. Add the user/group you want to give permissions to (and select the permissions you want to give), then check the box that says "Replace all child object permissions with inheritable permissions from this object".

UPDATE: Eating my own dog food, another real world scenario yesterday when we needed to reset all permissions on a folder with a few million files in it (and remove inheritance):

This was on Windows Server 2008 R2, so you need to run a CMD Prompt as Administrator (advisable for Server 2008 R2 and above). At the CMD prompt:

icacls E:\Store\*.* /grant:r "OURDOMAIN\Domain Admins":F /grant OURDOMAIN\ITAdmins:F /T /C /inheritance:r /Q

.

To explain each part of this command:

  • icacls
    • the command
  • E:\Store\*.*
    • the folder and files which need permissions reset
  • /grant:r
    • grant permissions and replace all existing permissions
  • "OURDOMAIN\Domain Admins"
    • user/group that we're giving permissions to (the quotes are needed because "Domain Admins" has a space)
  • :F
    • grant Full Access permissions
  • /grant
    • grant additional permissions (no need for :r this time)
  • OURDOMAIN\ITAdmins
    • an additional user/group to give permissions to
  • :F
    • grant Full Access permissions
  • /T
    • apply to subfolders too
  • /C
    • Continue on file errors (e.g. Access Denied)
  • /Q
    • Suppress all success messages i.e. don't tell me the millions of files that have the permissions applied, just tell me the ones which failed

For any files that fail, you may need to run TAKEOWN then run the icacls command again (on the failed files):

takeown /F E:\\Store /A /R /D Y

You may want to pipe output to a file because there isn't a "quiet" option on takeown.

Use takeown /? to see other options available.

3
  • Can I do this from the GUI? I couldn't find such option.
    – Sergey
    Sep 30, 2010 at 10:52
  • 1
    @Sergey - I've added instructions for the GUI method. Hope this helps. Sep 30, 2010 at 10:59
  • Thank you, it works! You finished a lot of painful hours of trying!
    – Sergey
    Sep 30, 2010 at 11:45
3

Simply Use :

ICACLS "PATH OF DIRECTORY (FOLDER)" /grant "USER":F /T

In Following example I am setting permission for Everyone to all sub-folders/files of a folder named Hardik in my D drive. then my cmd code would be like this,

ICACLS "D:\Hardik\*" /grant "Everyone":F /T

For more details please visit this link..

0

using this script in powershell.. save it as perm.ps1

param(
[string]$i
)

    Import-Module NTFSSecurity
    
    
      if(test-path $i)
      {
            write-host Taking ownership of Directory $i -fore Green 
            Get-Item $i | Set-NTFSOwner -Account 'qd'
            Get-Item $i | Add-NTFSAccess -Account 'qd' -AccessRights FullControl
     
            $items = @()
            $items = $null
            $path = $null
            get-childitem $i -recurse -force | ForEach {
           
                
                    $path = $_.FullName
                    Write-Host ...Setting permissions to $path -Fore Green
                    Get-Item -force $path | Set-NTFSOwner -Account 'qd'
                    Get-Item -force $path | Add-NTFSAccess -Account 'qd' -AccessRights FullControl
                }
       }

in powershell first issue "Install-Module NTFSSecurity" Then "perm.ps1 d:\yourfolder" Why would you use this? In case, the other solution does not work..

0

Step to change the permission for a folder and its subfolder files.

In Linux, you can notice various folders and files exist. You need to set appropriate permission and ownership to ensure proper work access.

The permission 755 is required to set for directories. (drwx.r-xr-x);

Three types of permission. • r- read • w- write • x- execute permission

            find /foldername -type d –exec chmod 755 {} \;

Example: find /var/www/user –type – exec chmod 755 {} ;

Permission 644 is vital for files. (-rw-r--r--);

         [find (filename) -type f –exec chmod 644 {} \;][1]

Example: find /var/www/user/ -type f –exec chmod 644 {} ;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .