How to reset windows permissions on a drive or folder after reinstalling windows

I had an issue after reinstalling Windows 10… a partition (D) and its folders had explicit permissions set during the previous Windows install…

To fix it, I ran the command through cmd as an administrator:


takeown /F D:\
takeown /F D:\/r /d y
icacls D:\ /grant Administrators:F
icacls D:\ /grant Administrators:F /t

Takedown: Enables an administrator to recover access to a file that previously was denied, by making the administrator the owner of the file. This command is typically used on batch files.

/r: recrusive

/d y: Suppresses the confirmation prompt that is displayed when the current user does not have the List Folder permission on a specified directory and instead uses the specified default value (y:yes).[/code]

icacls: Performs the operation on all specified files in the current directory and its subdirectories.

/t: Performs the operation on all specified files in the current directory and its subdirectories.