Created
July 31, 2012 14:08
-
-
Save Grynn/3217296 to your computer and use it in GitHub Desktop.
Reset Permissions on Folder Hierarchy in Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.