Windows 7 – How would I use Takeown to take ownership of all folders on one drive?

I have a hard drive which I need to recover specific files from but all the folders in the K: drive are denying me access even though I took owner ship of the full drive I.E

 

C:WindowsSystem32>takeown /F K:  This granted me access to the drive and see the folders but I can not access any of the folders after that.

Is there a way in which I can use Takeown to apply ownership to every directory on the drive>

Solution:

Is there a way in which I can use takeown to apply ownership to every directory on the drive?

This can be done in two different ways, using takeown or icacls.


Take Ownership of an Object using takeown Command

This command will take ownership of the folder or drive, and all files and subfolders in the folder or drive.

Open an elevated command prompt (administrator).

To grant ownership to administrators group:

takeown /F "full path of folder or drive" /A /R /D Y

To Take Ownership of a Folder or Drive and All Contents using icacls Command

Open an elevated command prompt (administrator).

To set administrators group as owner:

icacls "full path of folder or drive" /setowner "Administrators" /T /C

Further Reading

  • An A-Z Index of the Windows CMD command line – An excellent reference for all things Windows cmd line related.
  • icacls – Change file and folder permissions – display or modify Access Control Lists (ACLs) for files and folders.
  • takeown – Take ownership of a file (Windows 2003/7/2008).