Categories: Files

Take ownership of file or folder

In windows, some of the system files are protected by OS and can’t be accessed by users with even administrator privileges.  CSC cache stored in C:\Windows\CSC is one such folder. If you try to open the folder in windows explorer, you would be greeted with the window ‘You don’t currently have permission to access this folder.  Click Continue to permanently get access to this folder.”

For example, when I open the folder C:\MSOCache on my Windows 7 box, I see the following window.

The window says You don't currently have permission to access this folder.

By clicking on ‘Continue’ button, we can get access to the folder. IF UAC is enabled with ‘always notify’ setting, it would ask for confirmation again. Say yes and you can access the folder. By doing this step, we have gained ownership of the folder/file.

Take ownership of a file/folder from windows command line?

Open elevated administrator command prompt and run the below command on the file.

takeown /F fileName

Running from a non elevated command prompt would generated the error ‘Access is denied’

Take ownership of a folder and all its contents

c:>takeown  /R /F c:\windows\csc\
SUCCESS: The file (or folder): "c:\windows\csc\" now owned by user "domain\user".

These commands work on Windows 8 and Windows 7.

Srini

View Comments

  • I get access denied error running this command. I opened cmd with run as admin option and executed this.
    c:\Program Files (x86)\Adobe\Acrobat 11.0\Setup Files>takeown /R /F "{AC76BA86-1033-FFFF-7760-000000000006}"
    ERROR: Access is denied.

  • Alternate method:

    1. Open elevated command line.
    2. Run Psexec -i -s cmd.exe to open the cmd.exe as System.(utility from PS UTILs pack from Microsoft)
    3. cd c:\windows\csc
    4. You can run a directory and get access to the files as needed.

    • Cheers for this John! Read somewhere that you shouldn't really be messing about with permissions on this folder and have been looking for a way to get access to this for ages. You probably won't read this but wanted to say thanks for the solution!

  • Another alternate using only windows commands:
    • Right click on folder or file in Explorer (or other file manager where you can access properties)
    • Chose Properties | Security | Advanced | Owner
    • Select User Account name in "Change owner to"
    • Optionally check "Replace owner on subcontainers and objects
    • Apply changes by clicking the OK

Share
Published by
Srini

Recent Posts

Add new user account from command line (CMD)

Adding users from command line is much easier than going through the UI. It saves…

4 years ago

Delete directory from command line [Rmdir]

Do you want to delete a directory from Windows command prompt(CMD)? This post explains how…

4 years ago

TaskKill: Kill process from command line (CMD)

We can kill a process from GUI using Task manager. If you want to do…

4 years ago

Kill Chrome from command line

Chrome is definitely the stable browser compared to other ones and it has been my…

4 years ago

Find windows OS version from command line

Windows has multiple command line utilities that can help find the version of the Windows…

4 years ago

How to check if Windows 32 or 64 bit?

There are multiple ways to check whether a Windows computer is running 32-bit OS or…

7 years ago