How can I change permissions for the folder including subfolders?

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
  • "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.


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..