One of the things that annoys me most of Windows is its supposed user-friendliness. One of its prime examples is its stubborn refusal to delete or move a file when it thinks a process has locked it. Sometimes it does it right, not allowing you to disrupt a running process by removing one its open resources, more often it just gets in the way. Sometimes giving the same command from the console enables you to delete/move the file, sometimes not. A few days ago I was so frustrated by this behaviour that I set out to find a solution to it.
One of the first links that pops up in Google if you search for windows “cannot delete” points to a Microsoft KB article appropriately titled You Cannot Delete a File or a Folder. Among the usual suggestions like verifying ACLs or file system integrity, the document points you to yet another KB article titled How to: Display a List of Processes That Have Files Open, which seems more relevant to the problem at hand. This document suggests you to download Process Explorer, a little-known free utility that allows you to browse open processes, display and close their open file handles, and lots of other useful things. If you haven’t heard of it before, and develop on Windows or power-use it, I definitely recommend downloading it.