0

I have a folder on one of my hard drives, P:\csharp\aperture\keystone\src\Keystone, which I want to delete but cannot. I have tried numerous different ways to change/reset permissions and I still cannot delete this folder.

PS P:\csharp\aperture> whoami
azuread\mikelloyd

PS P:\csharp\aperture> rm -Recurse -Force .\keystone\
rm : Cannot remove item P:\csharp\aperture\keystone\src: The directory is not empty.
At line:1 char:1
+ rm -Recurse -Force .\keystone\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (src:DirectoryInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
rm : Cannot remove item P:\csharp\aperture\keystone\: The directory is not empty.
At line:1 char:1
+ rm -Recurse -Force .\keystone\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (P:\csharp\aperture\keystone\:DirectoryInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand

PS P:\csharp\aperture> rmdir .\keystone\

Confirm
The item at P:\csharp\aperture\keystone\ has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Are you sure you want to continue?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A
rmdir : Access to the path 'P:\csharp\aperture\keystone\src\Keystone' is denied.
At line:1 char:1
+ rmdir .\keystone\
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (P:\csharp\aperture\keystone\:String) [Remove-Item], UnauthorizedAccessException
    + FullyQualifiedErrorId : RemoveItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.RemoveItemCommand

PS P:\csharp\aperture> icacls.exe .\keystone\ /reset /T
processed file: .\keystone\
processed file: .\keystone\src
.\keystone\src\Keystone: Access is denied.
Successfully processed 2 files; Failed processing 1 files

I don't have read privileges.

no read privileges

It can't show the owner:

no owner

If I try to change the owner, I don't have permission to view or edit the object:

enter image description here

What is really strange is that I created the folder with my user, so I should be the effective owner. I have tried to delete the user as Administrator, but I can't do that either. I can't even delete the folder as NT\System:

P:\csharp\aperture\keystone\src>whoami /user

USER INFORMATION
----------------

User Name           SID
=================== ========
nt authority\system S-1-5-18

P:\csharp\aperture\keystone\src>rmdir /S Keystone
Keystone, Are you sure (Y/N)? Y
Access is denied.

nt system authority

How can I delete this folder that I created?

  • You forgot to mention what sort of "drive" this is? – Michael Hampton Mar 24 '19 at 2:11
  • It's a local hard drive, formatted as NTFS. – mxplusb Mar 24 '19 at 2:19
  • What's the Azure AD stuff about, then? – Michael Hampton Mar 24 '19 at 2:25
  • P: is definitely a local drive? And your account is definitely a local admin account? And you can’t take ownership of the folder? That’s your real requirement: you want to take ownership. Once you’ve done that everything else should be easy. – Todd Wilcox Mar 24 '19 at 7:22
  • My user is set up through AzureAD (I own that system). P: is a local drive, I have local admin privileges (and can log in as Administrator), and I cannot take ownership. I've tried to take ownership as Administrator as well, I can't do that either. – mxplusb Mar 24 '19 at 7:26
0

Try out this: First, check if your User Account is Administrator. Run cmd as administrator, type in takeown /f P:\csharp\aperture\keystone\src\Keystone , this should give you ownership of the directory. lastly, type rmdir /q /s P:\csharp\aperture\keystone\src\Keystone if it still doesn't work, try the same steps in Safe Mode. I hope this helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.