If you’ve ever been denied access to a file or folder in Windows, chances are you need to take ownership of them with your user account. Here’s how.

Right-click the object and choose “Properties.”

In the Properties window, on the “Security” tab, click “Advanced.”

Next to the listed Owner, click the “Change” link.

Type your user account name into the “Enter the object name to select” box and then click “Check Names.”

When the name is validated, click “OK.”

Click “OK” twice more to exit out of the properties windows.

In Windows, a user that has ownership of a file or folder has implicit rights to change permissions on that object. That user is also always allowed to access the file or folder—even when other permissions seemingly contradict that access. When you create a file or folder, the user account under which you’re logged in automatically gets ownership.

But you might occasionally run into a situation where you need to take ownership of a file or folder. Maybe you’ve got files or folders that were created by a user account that has since been deleted. Maybe you’ve got a hard drive from another PC that you’re working on. Or maybe you just need access to a particular system file—like “notepad.exe”— so you can apply a hack. Whatever your reason, here’s the official way to take ownership of a file or folder. And once you’ve learned how to do it, why not make it even easier and add a “Take Ownership” command right to your context menu?

First, make sure you’re logged on with an account that has administrative privileges. By default, any administrative account can take ownership of a file or folder in Windows.

Right-click the file or folder and choose “Properties” from the context menu.

In the Properties window, switch to the “Security” tab, and then click the “Advanced” button.

In Windows 8 or 10, in the “Advanced Security Settings” window, click the “Change” link next to the listed owner.

In Windows 7, the “Advanced Security Settings” window has a separate “Owner” tab where you’ll make these changes. On that tab, click the “Edit” button and then click the “Other Users or Groups” button on the subsequent page.

From that point, the rest of the instructions in this article apply whether you’re using Windows 7, 8, or 10.

In the “Select User or Group” window, in the “Enter the object name to select” box, type your user account name, and then click the “Check Names” button. If you typed a valid name, the name should change to show the full user name path with the PC name before it. You can then click the “OK” button.

NOTE: If you’re using a Microsoft account (rather than a local account), your official user name is just the first 5 letters of the full email address you used to set up the account. You’ve probably also noticed that those five letters were also used to name your user folder.

Back in the “Advanced Security Settings” window, you’ll see that your user account is now listed as the owner of the object. If it’s a folder, you’ll also see an option under the owner named “Replace owner on subcontainers and objects.” Make sure that’s selected and then click “OK.”

And back on the “Security” tab of the file’s Properties window, click the “OK” button.

You should now have full ownership of and access to your file or folder.