Skip to content

Instantly share code, notes, and snippets.

@Grynn
Created July 31, 2012 14:08
Show Gist options
  • Save Grynn/3217296 to your computer and use it in GitHub Desktop.
Save Grynn/3217296 to your computer and use it in GitHub Desktop.
Reset Permissions on Folder Hierarchy in Windows
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET TGT=%1
SET TGT=%TGT:"=%
IF "%TGT%"=="" SET TGT=*
takeown /f "%TGT%" /R /D Y > nul
icacls "%TGT%" /reset /t /q
icacls "%TGT%" /grant %USERNAME%:F /t /q
attrib -r -h -s "%TGT%" /s /l /d
@Grynn
Copy link
Author

Grynn commented Jul 31, 2012

Usage:
reset_perms "Some Folder" will recursively take ownership of all files in the folder (and sub folders), then reset ACLs to default, grant the current user FULL permissions and reset attributes.
Particularly useful when dealing with access denied errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment