Every so often I run into a file that I need to take ownership of. I normally use cacls
for changing ntfs permissions, but it doesn't seem to do ownership. Under *nix I would run something like chown me:me <file>
. Is there a windows equivalent to chown
?
You're looking for "TAKEOWN.EXE", which was first in Windows Server 2003 as a standard component, and I believe a resource-kit item prior. It is available on Windows 7, and perhaps newer systems.
/r
performs the operation recursively on all children of the specified folder. Unlikesubinacl
, you must log in as the user you are trying to take ownership with; or, you can simply assign ownership to the "Administrators" group.Here's a copy of its documentation, as preserved on SS64:
subinacl is a Windows sysadmin's power tool for doing everything to do with ownership and ACLs. You can change the ownership to anyone other than just you (you can't do this with the GUI).
This lets you set the permission to any user you like, without having to be an administrator (as I believe takeown.exe requires).
Take ownership and full rights of folder and everything inside:
Make sure to start the Command Prompt as Administrator!
I had to start a Command Prompt as Administrator, it worked for me in Windows 8.1. With Windows 8.1 awkwardness, I had to search for "command", right click on the Command Prompt icon. For me in order to see the "Run as Administrator" option. I had a Command Prompt pinned to my Taskbar, but right clicking on it would not show the "run as Administrator" option.
In Windows 10, "Run as Administrator" should be available to you as a right click option.
Takeown Syntax:
takeown Reference.
Icacls Syntax:
icacls Reference.
I know this is a really old post, but there is a way built into Windows 7 and newer (may be in Windows Vista, but I am not sure). Run the following from an escalated command prompt in the folder that you want reset.
/t
tellsicacls
to perform the operation recursively.The first command resets the owner to who ever is logged on via the environment variables. Of course, a specific name can be used instead.
The second command then forces the permissions to be reinherited down the tree to all of the child folders and files.
Hope this helps someone in the future.
You might want to take a look at SetACL, the swiss army knife of permission management. Here is an example of how to assign ownership of all files on drive C: to "Administrators" and remove protection of inheritance from all child objects in one go:
You can also add
-silent
.For Windows 2003, 2008 or Vista or 7 use Takeown.
For Windows 2000 use Fileowners.pl.
In Windows Server 2003 R2 (and later) you can take advantage of the built-in tool icacls.exe to change ownership from the command line, as well as all of the traditional cacls.exe manipulations upon which it expands...
Note that icacls.exe defaults to "edit" mode, while cacls.exe defaults to "replace" mode--a welcome change to those of us bitten (more than once) by that little nuance of cacls!
Another alternative is fileacl It is small and can set/unset "inherit/don't inherit" flag on the object, unlike most windows utils.
I've found a solution using Windows Tools: cacls
takeown /f *.jpg
icacls *.jpg /grant "Everyone":F
(note that in non-english Windows "Everyone" might not exist, e.g. in german Windows it only works with "Jeder" - real bummer that Windows translates command options!)