From time to time while working with windows o.s. we see the error "access is denied to this folder" when we are trying to delete a folder. The reasons can be many and so can be the solutions too. Here are some small tips/tricks that have worked for me and thought you too might find them useful.
1. Change Permission
If you need to delete a file (e.g., c:\got_to_go.exe) from your computer, but cannot because of permission errors, then you can get around this by changing the files permissions from the command prompt by doing the following:
Cacls c:\got_to_go.exe /p username:w
This will change the permissions on the file from the System Account to the user that is currently logged in. Once this is done, you should be able to delete the file unhindered.
2. Remove Directory
if No.1 tip doesn't work, no problems, we can try to simply remove the folder. In cmd window, to remove a folder like c:\virus type:
rd /S \?\c:\virus\
and now the folder should be gone you will not even going to see this in recycle bin. The syntax “\?\” is used by volume shadow copy service and if you remove it you cant restore it via recycle bin.
3. Kill Process Locking the file
You can try killing those processes that are accociated with this folder or just kill urs shell process explorer.exe in task manager (in the process tab) and then try to delete it
4. Try a Reboot
Sometimes a rouge process might own the folder / file and it is not obvious useing Task Manager. Sometimes a reboot will clear it up, but not all that practical on a server, but might work for your local machine.
5. Check for Malware
If you havent run a virus check for a while, now might be a good time to double check.
6. Use a Utility
You can also use various utilities - things like Norton became famous for providing various disk utilities. Nowadays, there are lots to choose from. I can recommend the free utility called unlocker assistant to delete these folders. You can download from here http://ccollomb.free.fr/unlocker/#download
I hope this little tip help you to remove that irritating error :-D