How to take ownership of a file in Windows 7 and Vista

By default Windows 7 and Vista protect files and folders that it believes are important to the operating system. These files are even protected from users operating under administrative permissions. The reasoning behind this is two fold; first so the user doesn’t delete an important file which can render Windows unusable, and second to prevent spyware or a virus from interacting with system files.

Sounds all well and good, doesn’t it? The problem is occasionally Windows or another program will not release it’s hooks from a file after it is done using it. There are also instances where you really do want to change or replace a system file. Each of these situations will result in a “no go” from Vista or Windows 7. No delete, no change, no rename. Just a “you can’t do that” and an offer to try again!

Defrag.exe as an example

Let’s have a look at the windows defrag program. You can follow along by navigating to c:\windows\system32\defrag.exe. Right click on defrag.exe and select properties. In the window that opens click on the Security tab and you will see the following:

This tab allows you to see and edit security permissions for a file. With Administrator highlighted you can see that Windows restricts the actions to “Read” or “Read & Execute”, even for the computer Administrator. This means no one using this computer can rename, change, delete, or otherwise alter the file. Click on a few other choices in the upper window and see what the differences are. (It’s OK, I’ll wait…)

What you will find that only TrustedInstaller (part of the operating system) has full privileges.

Taking ownership of a file

All is not lost! There are actually three separate ways you can go about correcting the issue and I’ll show you two of them.

Taking ownership the old fashioned way – using the command prompt

Click the Start Orb and type cmd. This will produce “cmd.exe” as the result in the top of the window. Right click on “cmd.exe” and select Run as Administrator.

You will receive a UAC (User Account Control) warning, which you should approve.

Doing that correctly will open the window below (called the command prompt).

This is a command prompt with elevated privileges. (notice the word Administrator in the upper left), which will allow you to do things you could otherwise not do from a command prompt. You have told Windows that you want to have complete control and Windows displayed the UAC warning to double check your decision.

The first command to type at the command prompt is takeown /f filepath (takeown/ffilepath). Substitute filepath with the complete path to the file you wish to take ownership of. Using defrag.exe as an example the command would be takeown /f c:\windows\system32\defrag.exe

If you entered the command and filepath correctly when you press the enter key the command will be carried out and you will receive the following message indicating success.

The second command is icacls filepath /grant yourusername:f (icaclsfilepath/grantyourusername:f). Substitute filepath with the complete path to the file you wish to take ownership of. Substitute yourusername with the username you logged onto your computer with. Also notice there is no space between the username and “:f”.

Continuing with defrag.exe as an example I would type icacls c:\windows\system32\defrag.exe /grant David:f.

If you entered the command and filepath correctly when you press the enter key the command will be carried out and you will receive the following message indicating success.

Just for grins go back and check the properties of the file you took ownership of.

You can see that I have ownership of the file! This may seem a little complicated, or difficult. How about an easier method?

Taking ownership of a file the easy way – editing the registry

I promised easy and then tell you editing the registry is required. What am I thinking? :)

OK, where is the easy way. Open notepad (Start>Accessories>Notepad), highlight and copy the text between the lines below, paste into Notepad.


Windows Registry Editor Version 5.00

@=”Take Ownership”

@=”cmd.exe /c takeown /f \”%1\” && icacls \”%1\” /grant administrators:F”
“IsolatedCommand”=”cmd.exe /c takeown /f \”%1\” && icacls \”%1\” /grant administrators:F”

@=”Take Ownership”

@=”cmd.exe /c takeown /f \”%1\” /r /d y && icacls \”%1\” /grant administrators:F /t”
“IsolatedCommand”=”cmd.exe /c takeown /f \”%1\” /r /d y && icacls \”%1\” /grant administrators:F /t”


Your screen should look something like this:

Use File>Save As to save the file to your desktop. I suggest you choose a descriptive filename, such as “take_ownership”. Go the the desktop and change the file extension from “.txt” to “.reg”. This will allow you to automatically merge these instructions into the registry without having to manually edit the registry. I told you it was easy!

Double clicking the file will result in the following warning:

Clicking Yes will import the information directly into your registry, so you do not have to enter it manually. You will receive a confirmation which you can click Yes to.

That’s all well and good, you say, but what exactly does this thing do? Adding this to the registry adds an entry to the right click menu which allows you to take ownership with just a mouse click!

Let’s have a look at a protected file, after we have added this info to the registry.

There you have it! Oh, wait. There is more…

Added bonus! The super easy way!

I’ve created the registry files for you, which you can download and apply. Simply download the following files, change the extension from .txt to .reg, and double click to apply.

take_ownership – Adds Take Ownership function to the right click menu of protected files

remove_ownership – Removes the Take Ownership function


  • Always backup your computer before changing system settings!
  • Always backup your registry before making edits or merging files.
  • Use Take Ownership responsibly. This is an important security feature in Vista and Windows 7. As such, it should only be used when there is a need.
About the Author

David Hartsock

Executive Editor/Owner/Admin of Daves Computer Tips and all-around good guy - Dave's interest in computers began in the early 1980's during the Apple II era. In the early 1990's the PC began to replace proprietary and mainframe devices in Dave's industry so he began to learn and experiment with the PC. Through DOS, Windows 3.1, Windows 95, Windows 98, Windows 2000, Windows XP, Vista, Windows 7 and 8, and now Windows 8.1. Dave became the "go to" guy for friends, family, and coworkers with computer problems. Daves Computer Tips was born in 2006 in an effort to share these experiences with others in an easy to understand, plain English, form.

There are 6 comments

Comments are closed.