How do I delete a 'locked' file?

To successfully delete a locked file, you will need to identify the process which has locked the file. You need to exit the process first and then delete the file. To know which process has locked a file you need a tool such as Microsoft Sysinternals' Process Explorer (PE).

Once you have PE installed ...

  1. Click the Find menu, and choose Find Handle or DLL ...
  2. Type the file name (name of the file which is locked by some process.)
  3. After typing the search phrase, click the Search button

You should see the list of applications which are accessing the file :

Process Explorer

Now you can kill the offending process using PE or something else.


With Unlocker. You could also try booting into safe mode (or just rebooting) and see if you can delete it then.

Edit (2013-02-09): I've found something better. LockHunter.


Unlocker is good, but personally I prefer MalwareByte's FileAssassin.