Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete a folder that lost its owner

I have found myself in a somewhat unique situation.

I have a folder. This folder, somehow, lost its owner.

In "Advanced Security Settings for FOLDER" under "Current owner:" is displayed:

Unable to display current owner.

I am trying to delete this folder with no success. I have tried taking ownership with both my user and the Administrator user and both yield

Unable to set new owner on FOLDER, Access is denied

I have tried to grant administrator full privileges via the Windows shell running as administrator:

icacls FOLDER /grant administrators:F

And I have tried to remove the folder via the Windows shell running as administrator:

rmdir FOLDER /s

which return:

Access is denied

Does anyone have any idea as to how I can delete this folder?

like image 972
Gimli Avatar asked Jul 11 '13 17:07

Gimli


People also ask

How do I remove the owner of a folder?

Right-click on the target file or folder and select Properties. Select Security tab. Click Advanced button. Select the Owner tab.


2 Answers

If you tried to delete a file/folder and it failed due to a process holding on to it, it will lose it ownership. Use Process Explorer and do a search for the folder/file. It will show what process is using that folder/file. When you end the process, the folder/file will disappear.

like image 186
Gerhard Powell Avatar answered Sep 19 '22 15:09

Gerhard Powell


Try chkdsk /F in cmd with admin privilege!

Because the folder may contain a file without owner, which is an error in your file system.

If that folder is in your boot disk (C:), cmd will ask you whether to scan when the next time you launch the computer, type "y" to confirm.

After the scan chkdsk will delete the damaged file(s).

I got this problem after uninstalled Android Studio, I can't delete C:\Program Files\Android\Android Studio. Tried DEL/RD/TAKEOWN/ICACLS... for one hour, none of them works for me. Then I realized, that folder contains some damaged files without owner... Guess it's a bug of Windows or Android Studio...

This is one of the possibility why some folders or files cannot be deleted even with admin privilege.

Hope this helps the questioner and people who have the same problem!

like image 20
Kirk Avatar answered Sep 23 '22 15:09

Kirk