Windows – How to take ownership of files from the command line

access-control-listcommand-line-interfacentfswindowswindows-xp

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?

Best Answer

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).

subinacl /file test.txt /setowner=domain\foo

This lets you set the permission to any user you like, without having to be an administrator (as I believe takeown.exe requires).