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

13

9

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:\Windows\System32>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>

ThunderToes

Posted 2014-09-19T10:53:18.953

Reputation: 470

Answers

23

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

DavidPostill

Posted 2014-09-19T10:53:18.953

Reputation: 118 938

This worked for me, but I had to do it from a system level prompt. Running from a cmd.exe as Administrator was not enough. To do that, I first had to run psexec -i -s cmd.exe from an Administrator command prompt, then run the commands from this answer. – Andrew Brock – 2018-09-27T08:15:59.787

1

You will need to add a /R on your command to recurse throughout the subfolders and files...

CharlesH

Posted 2014-09-19T10:53:18.953

Reputation: 1 943

Remembering also that the NTFS permissions also come in to affect once you are the owner.. If the NTFS permissions does not allow access to the creator/owner then it will make no difference being the owner... – CharlesH – 2014-09-19T11:08:13.687

yes thank you for this I just this minute found it out haha – ThunderToes – 2014-09-19T11:08:57.117

1

Sorry Stupid question, but for future reference to other users, I used Takeown /? to find that I could write in CMD:

C:\Windows\System32>takeown /f K:\ /R

This then gave me permission to all folder and subfolders

If you use the takeown command or any command in CMD use /? to get the information on what features you can use and what they do.

ThunderToes

Posted 2014-09-19T10:53:18.953

Reputation: 470