# recursively change owner windows 7

Somehow i accidentally set all the files in a subfolder to no owner and i cant seem to change all the permission. I can change one by hand by changing the owner then setting permissions but how can i change owner of all the files in this directory at once?

-

Use takeown from the command prompt to take ownership a folder, all its subfolders and files recursively:

takeown /f "c:\folder\subfolder" /r


This works well, but if you don't run your command line console as administrator it may fail for files you don't own.

-

To fix really broken permissions, the best is to run these two commands one after the other:

takeown /f "C:\path\to\folder" /r
icacls "C:\path\to\folder" /reset /T


The first one will give you ownership of all the files, however that might not be enough, for example if all the files have the read/write/exec permissions set to "deny". You own the files but still cannot do anything with them.

In that case, run the second command, which will fix the broken permissions.

-
Excellent technical advice ... your solution was the only one that worked. Thanks again. – carrabino Aug 24 '14 at 21:11
Best advice, need to use both takeown and icacls. – gnac Dec 2 '14 at 23:41
This will fix problems even if there is a deny permission set – bradvido Sep 9 '15 at 14:22
/A option is useful if you wish to give 'ownership to the administrators group instead of the current owner'. You need to have Administrators privileges to do this. May need to open cmd window using ctrl-shift-enter. – PeterVermont Dec 2 '15 at 15:40
I've added the /D Y parameter to takeown so it auto-confirms recursed directories where you don't have 'list directory' permissions for. – Jeroen Wiert Pluimers Jul 6 at 14:51

Note that cacls is deprecated (since Windows Vista?) and it advises you to use icacls.

This command will recursively reset the permissions on a folder:

icacls "C:\path\to\folder" /reset /T

-

You can use cacls from the command prompt:

cacls "C:\path\to\folder" /E /T /C /G "Administrator":F

The /T switch allows it to function recursively. Replace Administrator with the user you wish to give permissions to.

-