Skip to content

Instantly share code, notes, and snippets.

@Samk13
Last active August 2, 2023 22:27
Show Gist options
  • Save Samk13/6bc798880a30687d66b2c43c18afd7df to your computer and use it in GitHub Desktop.
Save Samk13/6bc798880a30687d66b2c43c18afd7df to your computer and use it in GitHub Desktop.
Windows folder Permissions Cleanup

Context:

After a Windows reset, certain folders may retain permissions from non-existing accounts, leading to "Permission denied" errors. This Gist provides commands to take ownership, grant full permissions, and remove a specific folder on drive to resolve the issue.

# Take ownership and grant full permissions
takeown /F D:\Foldername p /R /A
icacls D:\Foldername /grant "YourUserName":(F) /T

# Remove the folder and its contents
rd /s /q D:\Foldername
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment