How to Take Ownership of a File or Folder Using Command-Line in Windows

In Windows Vista and higher, a command-line tool named Takeown.exe exists, that can be used from an Admin Command Prompt to change the ownership of a file or folder easily.

Taking ownership of a file

Open an elevated Command Prompt window. To do so, click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run as Administrator.

Type the following command and press ENTER:

TAKEOWN /F <filename>

(Replace the text <filename> with the full path of the actual file.)

If the operation was successful, you should see the following message:

"SUCCESS: The file (or folder): "filename" now owned by user "Computer Name\User name"."

Then to assign the Administrators group Full Control Permissions for the file, use the ICACLS command. Use this syntax:


ICACLS <filename> /grant administrators:F

Taking ownership of a folder

Use the following syntax:

takeown /f <foldername> /r /d y

Then to assign the Administrators group Full Control Permissions for the folder, use this syntax:

icacls <foldername> /grant administrators:F /T

The /T parameter is added so that the operation is carried out through all the sub-directories and files within that folder.

Command-line help: To know more information about the above commands, run these commands from a Command Prompt window.

takeown /?

icacls /?


#1 Command Script

To further simplify the process of taking ownership, Tim Sneath of Microsoft provides a .CMD file (Windows Command Script) which takes ownership and assigns Full Control Permissions to Administrators for the directory which is passed as a parameter to the CMD file. For more information, read Tim’s post Secret #11: Deleting the Undeletable.

#2 Add "Take Ownership" command to the Context menu

This again uses the special runas verb in Windows Vista and higher, which has been covered many times in this Website (REF runas).


Download takeown_context.reg and save to Desktop. Right-click on the file and choose Merge. Click Yes when asked for confirmation.

This adds an extended command named Take Ownership in the context menu for files and directories. To access the command, you need to press and hold the SHIFT key down, and then right-click on a file or folder.

Sample Scenario: Let’s assume that you’re trying to delete a folder for which you don’t have permissions (although you’re logged in as Administrator) and getting an Access Denied error:

Simply press and hold the SHIFT key down, and right-click on the folder that you want to delete. Click the Take Ownership command.

You should now be able to delete that folder!

29 thoughts on “How to Take Ownership of a File or Folder Using Command-Line in Windows

  1. Well, it seems very helpful, but for some reason it keeps saying “Access is denied” not sure how to get around this.

  2. Thank you so much! You’ve just help me to recover some files off my laptop’s fracked old hard drive! :)

  3. Please could any one let me know the command to restore the owner ship to “Trusted installer” as a default owner. steps i performed is :

    1- TAKEOWN /R /F “C:\Program files” (SUCCESS & now i could see owner is SYSTEM)
    2 – cacls “c:\Program files” /T /E /G ProgFiles:W (ProgFiles is the local group) – SUCCESS

    Now here i tried below to restore the ownership:
    icacls “C:\Program files” /setowner “NT SERVICE\TrustedInstaller” /t /c
    ( It gave me message saying , successfully processed 897 files, failed processing 1134 files. (and still i could see SYSTEM as owner and not Trusted installed). PLEASE HELP ME

  4. This has finally allowed me to delete Windows and other system files from my slave drive. Even after inputting all those commands myself by following other peoples’ guides and getting ownership, it would still ask for permission infinitely and never get deleted. I assume perhaps it’s the runas verb that did the trick (none of the other sites ever mentioned it.) Either way, thank you so much for this. I was about to resort to formatting the whole drive and go through tedious data transfers.

  5. I had converted to Windows 8 from 7. I backed up my files from Windows 8 manually. I then reinstalled Windows 8 (because I hated it), then when I went to copy files back from the backup drive, I couldn’t because I did not have access. Your info helped me straighten out ownership and I can access them normally. Thanks.

  6. Thanks so much! As part of recycling an old XP computer, I had backed it up with Acronis. I had then “wiped” the old XP drive. When I restored specific pictures from the old XP machine backup to a W7 attached USB hard drive, I did not have access. I thought I might have to resurrect the old XP machine. But the above “saved my bacon”!

Comments are closed.