How to Recursively Set NTFS Permissions for Network Shares in Windows 7 Using Command Line and GUI


2 views

When setting up network shares in Windows 7, many administrators face the issue where top-level folder permissions don't automatically propagate to existing files and subfolders. Unlike Unix's simple chmod -R, Windows requires explicit handling of permission inheritance.

For basic permission management:

  1. Right-click the shared folder > Properties
  2. Navigate to Security tab > Advanced
  3. Click "Change Permissions"
  4. Check "Replace all child object permissions..."
  5. Add "Everyone" with Read & Execute permissions
  6. Apply changes (this may take time for large directories)

For bulk operations, PowerShell provides superior control:


# Grant read permissions recursively to Everyone
$acl = Get-Acl "C:\SharedFolder"
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone","ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow")
$acl.SetAccessRule($rule)
$acl | Set-Acl -Path "C:\SharedFolder"

# To verify permissions:
(Get-Acl "C:\SharedFolder").Access | Format-Table IdentityReference,FileSystemRights,AccessControlType,IsInherited -AutoSize

The built-in ICACLS utility offers precise control:


:: Grant read+execute to Everyone recursively
icacls "C:\SharedFolder" /grant Everyone:(OI)(CI)(RX) /T

:: Reset inheritance and remove explicit denies
icacls "C:\SharedFolder" /reset /T
icacls "C:\SharedFolder" /grant:r Everyone:(OI)(CI)(RX) /T
  • Always test permission changes on a copy first
  • Network shares require both NTFS and Share permissions
  • Windows 7 has a 20-connection limit for simultaneous access
  • Consider using "Authenticated Users" instead of "Everyone" for better security

If permissions don't apply correctly:


:: Take ownership first if encountering access denied
takeown /f "C:\SharedFolder" /r /d y
icacls "C:\SharedFolder" /setowner "Administrators" /T

After migrating from Windows XP to Windows 7, many administrators encounter permission inheritance issues when setting up network shares. The core problem lies in Windows 7's more granular security model and the way it handles permission propagation.

The most efficient way to recursively set permissions is using the ICACLS command (Improved Change ACLs). This replaces the older CACLS utility and provides more control:

icacls "C:\SharedFolder" /grant:r Everyone:(OI)(CI)(RX) /T /C /Q

Let's break down the parameters:

  • /grant:r - Replace existing permissions (use just /grant to add)
  • Everyone:(OI)(CI)(RX) - Grants read/execute to Everyone
  • /T - Apply recursively
  • /C - Continue on error
  • /Q - Quiet mode

For those preferring graphical tools:

  1. Right-click folder → Properties → Security → Advanced
  2. Click "Change Permissions"
  3. Check "Replace all child object permissions..."
  4. Modify permissions as needed

Understanding the permission flags is crucial for precise control:

F - Full control
M - Modify
RX - Read and execute
R - Read only
W - Write only
D - Delete

To mimic Unix-style 755/644 permissions, you'll need two commands:

:: For directories (755 equivalent)
icacls "C:\SharedFolder" /grant:r Everyone:(OI)(CI)(RX) /T

:: For files (644 equivalent)
icacls "C:\SharedFolder\*" /grant:r Everyone:(R) /T

If permissions don't propagate correctly:

  • Ensure you're running Command Prompt as Administrator
  • Check for explicit deny permissions (remove with /remove:d)
  • Verify inheritance isn't blocked on child objects

For more complex scenarios, this PowerShell script provides better control:

$acl = Get-Acl "C:\SharedFolder"
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone","ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow")
$acl.SetAccessRule($rule)
Set-Acl -Path "C:\SharedFolder" -AclObject $acl -Recurse