Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Celoxocis/28c243ec217819eb549f0daf69552217 to your computer and use it in GitHub Desktop.
Save Celoxocis/28c243ec217819eb549f0daf69552217 to your computer and use it in GitHub Desktop.
Fix permissions on a roaming profile folder
REM usage: fix_perms.bat <username>
REM Recursively assign ownership to Administrators. Answer prompts with "Y".
takeown /R /A /F %1 /D Y
REM Grant Full permissions on folder and subfolders to Administrators, SYSTEM, and the user
cacls %1 /T /E /P "Administrators":F
cacls %1 /T /E /P SYSTEM:F
cacls %1 /T /E /P %1:F
REM Set owner back to UserName
subinacl.exe /noverbose /subdirectories %1\*.* /setowner=%1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment