2

I am not able to delete one folder on the desktop....if i try to delete i get the message as "Access is denied". I tried running the command from cmd prompt as an administrator:

RD /S /Q "C:\Users\username\Desktop\folder"

Still the same error.

I tried to change the permissions on the folder but still I am not able to do the changes I again get access denied. Any help will be much appreciated.

Dave
  • 25,513
senthil
  • 29

2 Answers2

2

The issue is that your user does not own the folder. You can review the folder permissions with the following command (from cmd.exe):

C:\>icacls C:\Users\username\Desktop\folder
C:\Users\username\Desktop\folder NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
                                BUILTIN\Administrators:(I)(OI)(CI)(F)
                                HOST\username:(I)(OI)(CI)(F)

Successfully processed 1 files; Failed processing 0 files

If the ownership doesn't look correct, you can take ownership and give yourself Delete permission:

C:\>takeown /f C:\Users\username\Desktop\folder /r /d y
C:\>icacls C:\Users\username\Desktop\folder /grant username:D /t

Once your user owns the folder and has the correct permissions, you should be able to rd /s /q C:\Users\username\Desktop\folder.

andrew
  • 56
1

Common cause of this problem is that a Process (like a Program) using the specified Folder right now. so you have to end the process. There are many methods you can see which process are using the Handles. You can use "Resource Monitor" program that have in-cloud with Windows. You can use Resource Monitor by typing "resmon.exe" in Start Search-box. in the CPU tab, at Associated Handles drawer you can put the Path of folder and search for process which have using it. then you can stop the process using this command in CMD.exe
taskkill /IM [PROCESSNAME]
Now maybe you can Delete the folder. (Also you can use Unlocker to find the process and end it)


The other method you can try is deleting folder from Safe-Mode.
Safe-Mode doesn't start the Third-party process, so there is no handle on the Folder expect a System file handled it.