A Folder in Windows has lost all permissions, how can I fix or delete it?

8

2

In Windows 10, I have a folder that has lost every permission and even the ownership.

If I choose right-click > Security, all lists of permissions are empty and it says the owner could not be evaluated. If I try to add a permission, e.g. of System, or try to change the owner, the settings are not stored.

I would like either to fix the folder or to delete and recreate it. But the system doesn't allow to delete, even if I start a shell or a file explorer as administrator.

What is the correct way in Windows to clean up such orphans?

Thanks a lot for any hint.


Edit Please see the picture below that illustrates how important option controls are missing. Also, chkdsk seems not possible immediately (but it can be scheduled).

enter image description here

peter_the_oak

Posted 2017-01-03T08:02:01.590

Reputation: 339

Answers

7

I would first suggest running chkdsk /f on the disk, which will make sure the security information isn't corrupted. It should restore the directory to some 'standard' permissions.

If you're an administrator, you should be always able to take ownership using takeown, and then write new ACL using e.g. icacls … /reset.

user1686

Posted 2017-01-03T08:02:01.590

Reputation: 283 655

1takeown /F was our rescue here :-) – peter_the_oak – 2017-01-06T14:25:58.747

4I am getting ERROR: Access is denied. with takeown /F <foldername>. – user2173353 – 2017-11-02T14:39:40.297

Restarting Windows removed the file. Seems it was a ghost file or sth... – user2173353 – 2017-11-02T14:59:55.783

2

Restart your computer. This may be a folder that has failed to delete, it should disapear on a restart and can be re-created safely

Mark

Posted 2017-01-03T08:02:01.590

Reputation: 31

I don't know why this got a downvote - I had this issue, and this was exactly the solution in my case. Same for user2173353 according to the comment on the accepted answer. – Syndic – 2019-02-28T07:47:51.120

1

On the parent folder, right click, choose properties, security.

From there go to Advanced

If you are using a standard user, press the button Change permissions and supply administrative credentials.

You should now see a checkmark at the bottom stating:

[ ] Replace all child object permission entries with inheritable permission entries from this object.

Check this checkbox and press Apply.

Every subfolder will now get their permissions reset, including the one you lost access to.

If you can't afford any other folder to be affected, you can try to move the folder in question to a new folder and try it as such, or move all other folders away.

LPChip

Posted 2017-01-03T08:02:01.590

Reputation: 42 190

Important controls are missing, please see the picture I've added. That's why I'm stuck with the context menu way. However your suggestion is the right start. Would it make sense to dig deeper with powershell? – peter_the_oak – 2017-01-03T09:58:11.417

You need to go higher in the directory tree until you find a folder you have access to. Do note that the inetpub folder is part of IIS and altering permissions may cause IIS to stop working correctly. – LPChip – 2017-01-03T11:03:54.257

If you're an administrator, you should be always able to take ownership using takeown, and then write new ACL using e.g. icacls … /reset. – user1686 – 2017-01-03T11:04:40.770

@LPChip thanks for the extra explanation. You are right in mentioning IIS. Some of the folders there have additional write permissions for the IIS_IUSRS. By reinitializing the permissions from the parent, I have to correct those permissions. Would be easy if I had direct access to the machine. So this way became the fallback solution. Luckily, takeown worked. – peter_the_oak – 2017-01-06T14:41:32.633

0

I just had a similar issue where ICACLS and the TAKEOWN commands were not getting it done. I was using ICACLS and after finding this post I also tried TAKEOWN:

icacls N:\* /grant UserName:(oi)(ci)f
takeown /F N:\*

What finally corrected the issue was explicitly setting the INHERITANCE switch in ICACLS:

icacls N:\* /grant UserName:(oi)(ci)f /inheritance:e

DBADon

Posted 2017-01-03T08:02:01.590

Reputation: 259