
Cannot delete filename: Access is denied.
Make sure the disk is not full or write-protected and that the file is not currently in use.
Sound familiar?
Over the years, I have stumbled into this error more times than I care to count. And I’m pretty sure the culprit is doing rsync backups from my Linux server to my Windows file server using CygWin. I finally think I have a fix, though. This is working in Windows XP and I assume that it will work in Windows Server 2000 and 2003 and maybe even Vista, Windows 7, and Server 2008 (as long as it’s Windows NT-based and NTFS).
If it’s a single file:
- Right-click on the offending file and go to properties.
- Go to the Security tab.
- Click on the Advanced button in the bottom right (above OK, Cancel).
- Go to the Owner tab.
- In the “Change owner to” frame, highlight your username, and then click Apply in the bottom right.
- Click OK a couple of times to get back to your file.
- Right-click on the file and go to properties (yes, again)
- Go back to the Security tab.
- Click on the Advanced button again.
- Make sure you are in the Permissions tab.
- Click the “Allow inheritable permissions from the parent to propogate …” checkbox.
- Click OK a couple of times to get back to your file. You should be able to delete it!
For a directory:
- Right-click on the directory and go to Properties.
- Go to the Security tab.
- Click on the Advanced button.
- Go to the Owner tab.
- Highlight your username.
- Click the “Replace owner on subcontainers and objects” checkbox.
- Click OK a couple of times to get back to the directory.
- Right-click on the directory and go to Properties (again).
- Go to the Security tab.
- Click on the Advanced button.
- Make sure you are in the Permissions tab.
- Click the “Allow inheritable permissions from the parent to propogate …” checkbox.
- Click the “Replace permission entries on all child objects …” checkbox.
- Click OK a couple of times. You may have to tell a pop-up message Yes.
- Delete the directory!
That’s been bothering me for years and nobody else seems to have had that problem (that or my Google-fu sucks). So, I’m putting this out there so that Google will pick it up and hopefully help out somebody else.
It’s funny you posted this just days after I came across this:
http://ccollomb.free.fr/unlocker/
Especially useful because it tells you what is locking your files/directories. I haven’t had the need to try it out in the past week but the next time I get locked out, I’ll be ready.
I searched LifeHacker.com for stuff like that, but the two that I tried failed miserably. :-/