16

I have a folder that I am unable to delete.

I also cannot take ownership.

The hard drive is one I have previously used in another PC, if this makes any difference.

When trying to take ownership it says it cannot display the current owner and when trying to take ownership selecting any group says access denied.

I've also tried via the command line using takeown however this too says Access Denied.

Windows 7, and I am logged in as an administrator.

4
  • 1
    If you need to delete it and Windows is not allowing you to do so, boot from a Linux Live CD/USB and get rid of the folder.
    – Karan
    May 5, 2013 at 20:27
  • Is it on an external drive? USB or similar? Jan 30, 2014 at 14:40
  • Karan's advice is particularly good for folders with thousands of files because rebooting to Linux is much faster than waiting for take ownership to complete.
    – ndemou
    Jun 15, 2017 at 22:05
  • Try rebooting the system. Sometimes when a file or folder is already sort of deleted, but still locked by some driver, it remains visible but inaccessible. After system reboot such files and folders go away. Jul 15, 2022 at 0:54

1 Answer 1

18
  1. Download PsExec.exe from Sysinternals, this tool allows you to open a command prompt under LOCAL SYSTEM privileges: http://live.sysinternals.com/psexec.exe (put it in C:\temp)

  2. Open a command prompt with Administrator Privileges

  3. CD into C:\temp

  4. Run: psexec -s -i cmd.exe, this installs a temporary service which will open a command prompt under LOCAL SYSTEM account. The service will be automatically deleted after you close the screen (i.e. after EXIT)

  5. Run: TAKEOWN /F <folder> /R /D Y, this will set the Administrators group as owner, it also recurses into the folder

  6. To give the Administrators group full control rights, run ICACLS <folder> /grant administrators:F /T; the /T indicates that this operation is performed on all matching files and directories below the directories specified

11
  • 1
    Thanks, but it still says Access Denied when trying through the cmd prompt opened by psexec
    – fileperms
    May 4, 2013 at 16:04
  • 8
    Could be it's locked by some process. Take a look at link if there's something you can use.
    – Heebr
    May 4, 2013 at 16:40
  • 1
    If this still doesn't help, try resetting permission (Inherit from above) and give Full rights to everyone by subsequently executing: 1: 'ICACLS <folder> /reset /T', 2: 'ICACLS <folder> /setowner everyone', 3: 'ICACLS <folder> /grant everyone:F'
    – Heebr
    May 4, 2013 at 19:43
  • 2
    takeown must have parameter /A specified to assign ownership to the Administrators instead of the local system account. Nov 15, 2014 at 21:18
  • 2
    perform file system check (chkdsk on Windows) - perhaps the file system is damaged
    – Zrin
    Nov 14, 2016 at 13:04

Not the answer you're looking for? Browse other questions tagged .