Can't delete folder and I am admin. "You need permission to perform this action. You require permission from..."

154

46

I can't delete a certain folder in Windows 7. It's not a system folder. It was created by an app. I get an error message "You need permission to perform this action. You require permission from Tony....". I am an admin and logged in as myself Tony. I have full ownership of the folder with full control permission. I rebooted the machine. I killed the app which created the folder. I am out of ideas.

Why is Windows 7 not letting me delete the folder?

Tony_Henrich

Posted 2010-10-29T17:28:41.837

Reputation: 9 154

You are not an administrator. You are said that you have his rights. Wrongly. The receipt is very simple, look this answer below: http://superuser.com/a/1119561/134259

– Gangnus – 2017-02-06T12:49:46.433

3I am in the administrators group. – Tony_Henrich – 2017-02-07T16:14:59.627

Have you got any background processes: TortoiseSVN, Anti-virus softwares, etc. that might be hanging on the folder (though I agree this is unlikely after a reboot). Alternatively have you tried deleting it while in safe mode? – PeterJCLaw – 2010-10-29T18:33:17.300

No idea why, but if safe mode deletion doesn't work, you could boot your system from a live CD of some sort (like Linux) and go directly into the file system and delete the file. This would undoubtedly work, but if some process is actually using the file, then it might break that process (when you reboot into Windows) with unknown consequences for the rest of your system, so make a backup of the file so you can put it back if things start to go south. – Joe – 2013-02-11T19:47:48.067

Just a thought: What are the attributes of the folder and everything under it? If something is set to read only (or maybe system), then you would probably have to remove those attributes before you could delete it even if you own it and are an admin. I haven't worked at that level in Windows for a long time, but that's how it used to work. – Joe – 2013-02-11T19:54:07.580

Answers

58

The only way was to delete files starting from the lowest level folder in that folder. I got that error message with every folder which had subfolders. I deleted all files/subfolders working my way up.

Tony_Henrich

Posted 2010-10-29T17:28:41.837

Reputation: 9 154

You may also want to restart, because we're on Windows and that's a thing. Drove me crazy for 15 minutes, but a restart fixed it after following Wilee's instructions. – Vael Victus – 2015-04-24T23:21:43.947

I've built a small program node-purgewindir that does exactly that. Deletes a directory by deleting every subdirectory recursively starting with the deepest nested subdirectories first

– Chris – 2016-04-03T08:42:11.103

3why does this occur? – Jason S – 2016-06-01T18:42:47.780

11I can't do this because "Access is denied" when trying to open it. – User – 2016-12-08T17:12:03.753

http://superuser.com/a/1119561/134259 – Gangnus – 2017-02-06T12:53:25.107

For me I just had to delete a single file, which was nested three levels deep, and then I could delete the rest. (Win 10) – Colm Bhandal – 2019-04-19T09:52:51.993

13That's the only thing that worked for me as well. – BioGeek – 2012-04-05T10:06:29.333

6Try this: Properties -> Security -> Advanced. Ensure the owner is assigned full control permissions. Change Permissions, check "Replace all child object permissions...", Apply. Now try to delete. The analog solved same problem for me under Win8, if certain details are slightly different. – wilee – 2012-11-24T17:37:53.353

119

I am not sure why this happens but there is a workaround.

To take control of the folder containing the undeletable create a text file called “delete.bat” and add the following lines to it:

SET DIRECTORY_NAME="C:\Locked Directory"
TAKEOWN /f %DIRECTORY_NAME% /r /d y
ICACLS %DIRECTORY_NAME% /grant administrators:F /t
PAUSE

You will need to change the directory path to match your requirements e.g. “C:\Locked Directory” to “C:\Delete Me”.

Right click on the file “delete.bat” select “Run As Administrator” and you should now have full control of the directory and all sub directories meaning you can do what you wish with them.

Sahil

Posted 2010-10-29T17:28:41.837

Reputation: 1 859

1Windows 8.1 - Files & Folders were created remotely through SMB, only this was able to take ownership. Afterwards I still could not remove the files (Error message told me to get permission from myself) but the Advanced Security Dialog was THEN able to fix the permissions using the inheritance clean-up checkbox. After this I could remove the files. – dualed – 2015-06-11T06:31:03.253

1the second line just tells me "access is denied". – peter – 2018-05-07T06:58:06.557

Now it says I need permission from myself to delete the directory. I gave myself full control of the directory and logged out and back in. Same thing. – Josh Withee – 2018-08-31T14:14:20.457

Both commands succeed, I now have ownership for 'Administror' to directory. I then had to do 'rmdir /s %DIRECTORY_NAME%' in order to delete directory, even though it was empty, otherwise I got 'Access is denied.' – arberg – 2018-10-20T09:14:43.423

This worked for me (up to a point), but only after I changed "administrators" to my own login name. After that there were still a couple of files left that I could not delete because they were in use. Now to find out what program is using them. – Marnix A. van Ammers – 2018-11-22T21:46:44.530

46Tried it but it didn't work. – Tony_Henrich – 2010-10-29T18:20:51.670

1That is a bummer. I was faced with a similar issue on a Windows 7 (64 bit) machine and this worked like a charm. – Sahil – 2010-10-29T21:26:55.487

ERROR: The current logged on user does not have ownership privileges on "...." --- aka, doesn't work – Yaakov5777 – 2019-04-12T06:51:16.943

Worked for me, this should be the accepted answer. – Maxim Egorushkin – 2019-04-27T22:56:26.570

This is the only thing that actually worked for me after trying too many things. Thanks a lot! – Aenadon – 2019-10-04T09:13:54.547

Note that both the /d y and administrator groups are language specific and you'll need to change those for the ones of the language of the OS – Winter – 2020-02-02T22:05:27.830

6It would have been nice if Microsoft fixed this bug in Sp1. This is a massive fail, and I curse each time I have to delete deep nested directories. – ozczecho – 2011-04-07T06:12:00.410

1+1 I had two system owned folders on a secondary drive that were created by the OS prior to my Win 8 -> 8.1 upgrade. Even through the Advanced Security dialog (MS's preferred approach), I could not take ownership to delete. This worked like a charm. – Joseph Ferris – 2013-09-20T14:49:41.030

31

A folder can disallow a parent from overwriting its permissions, so it stops working at a certain depth.

Use Process Monitor and filter for ACCESS DENIED events to figure out this depth

Every time an ACCESS DENIED event occurs change the permissions as explained by @Sahil.


You can use Handle too see what processes are opening files within your folder.

handle C:\Path\To\Folder\You\Are\Trying\To\Delete

Example:

C:\Windows\system32>handle C:\Windows\System32\inetsrv

Handle v3.45
Copyright (C) 1997-2011 Mark Russinovich
Sysinternals - www.sysinternals.com

svchost.exe   pid: 1500  type: File  134: C:\Windows\System32\inetsrv\config\schema
svchost.exe   pid: 1500  type: File  1B4: C:\Windows\System32\inetsrv\config\schema
svchost.exe   pid: 1500  type: File  1BC: C:\Windows\System32\inetsrv\config
svchost.exe   pid: 1500  type: File  1CC: C:\Windows\System32\inetsrv\config
svchost.exe   pid: 1500  type: File  1D0: C:\Windows\System32\inetsrv\config
inetinfo.exe  pid: 1572  type: File  3C:  C:\Windows\System32\inetsrv\en-US\inetinfo.exe.mui
inetinfo.exe  pid: 1572  type: File  188: C:\Windows\System32\inetsrv\MBSchema.bin.00000000h
inetinfo.exe  pid: 1572  type: File  190: C:\Windows\System32\inetsrv\MBSchema.bin.00000000h
inetinfo.exe  pid: 1572  type: File  1BC: C:\Windows\System32\inetsrv\MetaBase.xml
inetinfo.exe  pid: 1572  type: File  1D4: C:\Windows\System32\inetsrv\MBSchema.xml
svchost.exe   pid: 1884  type: File  1AC: C:\Windows\System32\inetsrv\config\schema
svchost.exe   pid: 1884  type: File  1C0: C:\Windows\System32\inetsrv\config
svchost.exe   pid: 1884  type: File  1C4: C:\Windows\System32\inetsrv\config

Tamara Wijsman

Posted 2010-10-29T17:28:41.837

Reputation: 54 163

5Using handle command in cmd line is the only thing that worked for me! – Steven Xu – 2014-11-18T03:07:14.767

1Thank you for your answer. handle utility helped a lot – Sharikov Vladislav – 2017-05-11T09:55:19.603

1The handle program was wonderful. – MxNx – 2017-10-05T20:51:37.590

Worked great in Windows 10 too :) – Doug McLean – 2017-10-31T09:53:18.807

Thanks for the help, with your information I've managed to detect which process has a handle associated with that folder without using external programs. Using Resource monitor from windows 10 on CPU tab > Associated handles panel and there I type the folder name in the search bar. And found the associated process Id. – mihkov – 2019-03-26T09:35:39.157

Late to the party, but can confirm that this resolved my issue. – mike.thorn – 2019-11-11T13:35:28.770

1This is a good tip. My problem was that I wanted to delete a folder, but I got an Access Denied error. The folder properties showed that I had no permissions to even change the ownership of the folder. I used Process Explorer and used the Find Handle search to find which process had a handle to the locked directory. Then I killed the process, and everything was working again. – Mas – 2012-11-27T15:03:00.890

21

Had this issue today with a Windows Update folder and would like to supplement the answer.

When permissions on a folder are correct (example below, with Admin being the administrator account I was logged in with):

enter image description here

But permissions on subfolders are different and do not propagate from the parent even though you tell them to, causing problems when trying to delete the parent folder:

enter image description here

Open a command prompt (personally, I did not need to elevate the prompt) and run

ICACLS <FolderName> /reset /T

enter image description here

To replace Access Control Lists with default ACLs, traversing all subfolders. After this try deleting the folder.

mxl_

Posted 2010-10-29T17:28:41.837

Reputation: 1 055

2Still doesn't work for me: "Accès refusé." which mean "refused access". Thanks anyway, what a pain to get "root" access on windows pffff.:/ (I was in a command line started as administrator) – pdem – 2016-01-09T18:56:10.977

1I'm getting handle is invalid error. Any idea what that means? – James Draper – 2017-02-05T18:31:58.423

11

I had this issue and tried several of the answers here to no avail. However, I was able to simply delete the entire folder I was having problems with from an elevated command prompt like so:

rmdir "C:\path\to\folder" /s

Hope this helps someone.

Bryan

Posted 2010-10-29T17:28:41.837

Reputation: 710

This is exactly what I did too... can't believe I had to look through every answer to find someone else who did the same thing. IMHO should be the first thing anyone tries. – u8it – 2016-10-20T01:35:45.190

Yes, this works, but you have forgotten to mention, that you should open the cmd window as an administrator. It is NOT the same as being a user with rights of administrator. – Gangnus – 2017-02-06T12:46:18.213

4Opened CMD as administator, but still: C:\ws>rmdir "C:\ws\preact-material-components" /s C:\ws\preact-material-components, Are you sure (Y/N)? y Toegang geweigerd. (access denied) – Stijn de Witt – 2018-04-28T14:11:29.280

1Still gives me "Access is denied" – TrojanName – 2018-12-12T12:11:07.487

Combining this with another answer's suggestion of icacls foldername /reset /T worked for me. (I'd earlier also taken ownership of the folder) – M.M – 2020-01-15T01:52:33.717

6

download SysInternals Suite and use the following utilities

use Process Explorer and Process Monitor to find out whats happening with your file

or use the following stand alone utils

use AccessChk to get details not easily available via the GUI

use PSFILE to scan for any process that is holding the file open then try the MoveFile utility to schedule a file delete in the next boot cycle.

The answer you're looking for will show up in the output of one of these utilities

kloucks

Posted 2010-10-29T17:28:41.837

Reputation: 241

Process Explorer has just helped me out with exactly this problem - great tool. – zifot – 2011-12-20T20:19:40.240

4

When I run into a folder/file I can't delete and rebooting doesn't free the file. I will add to the security setting of the file/folder the Everyone group and set the permissions to Deny Full Control. Then when I reboot the machine, what ever was using the file/folder starts, it won't be able to read/write or lock the file/folder. Finally with nothing being able to use the file/folder, you will be free to delete it.

Hope this helps.

Scott McClenning

Posted 2010-10-29T17:28:41.837

Reputation: 3 519

4

No go with Windows 7 Ultimate x64. Finally had to boot from a USB-based linux OS (which ignores file permissions in NTFS file systems) and delete the offending directory that way.

Steven Buehler

Posted 2010-10-29T17:28:41.837

Reputation: 41

1That's a bit much for a Windows user (even though I suggested the same thing before I read your answer ;) ), but an rm -rf of the subdirectory tree is sure a lot faster than the other methods! The issue is that something could break when Windows starts up again and the offending process or whatever can't find the folder/files. – Joe – 2013-02-11T20:05:20.540

2

I assume UAC is enabled and you are trying to delete the folder from Windows Explorer. You should run Windows Explorer as administrator (right click on the icon and select "Run as administrator") and then delete the folder.

The other alternative is to disable UAC, but I wouldn't recommend it.

ncardeli

Posted 2010-10-29T17:28:41.837

Reputation: 326

1UAC is off and I am logged in as admin. I tried your method and still same problem. Plus UAC is just a warning and if you say Yes, it continues with its process. – Tony_Henrich – 2010-10-29T18:13:31.807

@Tony UAC does actually do some other things. I have some legacy applications that won't run under Windows 7 with UAC turned on even if you accept the prompts (in fact, even if you have the prompts turned so low you don't get any running these apps!) I really wish I knew WHY this is, but it is. – Shinrai – 2010-10-29T18:53:17.817

2

You can use Unlocker utility to delete such folders.

It is very simple to use and it is completely free.

user1336087

Posted 2010-10-29T17:28:41.837

Reputation: 148

To be specific the software is IOBit Unlocker - the above link is an affiliate link. This suggestion worked perfectly for me on Windows 10 to delete a domain user locked download. – robertmoggach – 2019-01-28T19:44:15.450

@mogga: I'm pretty sure the link would have changed in the last 5 years now. – user1336087 – 2019-01-29T13:44:54.940

Every other solution didnt work. It was locked completely. IOBit savec my ass. – Fredy31 – 2020-02-27T19:08:30.790

1

Well, this happens for files that were installed by some kind installer, like under the TrustedInstaller user.

You need to pwn the file first,

  1. Right click the file, go to Properties/Security/Advanced.
  2. Owner tab/Edit/Change the owner to you (Administrator), save.
  3. Now you can go back to Properties/Security/ and assume Full Control over the file

bobobobo

Posted 2010-10-29T17:28:41.837

Reputation: 4 632

0

I had the same issue (Windows required permission from user X, while being connected as user X…):

enter image description here

I fixed it using unlocker (free, Microsoft Windows), then did:

enter image description here

enter image description here

After that, I could delete the directory without further issue.

Franck Dernoncourt

Posted 2010-10-29T17:28:41.837

Reputation: 13 518

0

Try moving the folder to your Desktop and deleting it there, odd, but has worked for me under similar circumstances.

Tog

Posted 2010-10-29T17:28:41.837

Reputation: 4 747