Windows won’t allow you to modify files that open programs have locked. if you try to delete a file and see a message that it’s open in a program, you’ll have to unlock the file (or close the program).
In some cases, it may not be clear which program has locked a file – or a background process may have locked a file and not terminated correctly. You must unlock the stubborn file or folder to modify it.
Note: Unlocking certain files and deleting them may cause problems with open programs. Don’t unlock and delete files that should remain locked, including Windows system files.
UnlockerUnlocker is a useful utility for unlocking files. With Unlocker installed, you can right-click a stubborn file or folder and select Unlocker. (Note that Unlocker tries to install the Babylon toolbar during the installation process – you’ll want to uncheck this.)
Process ExplorerYou can also unlock a file in the excellent Process Explorer task manager. First, launch Process Explorer as Administrator – you can do this from within Process Explorer by clicking File and selecting Show Details for All Processes.
Restart Your ComputerGenerally, a file won’t be locked after you restart your computer – unless the program that locked it is a startup program that locks the file as soon as you log in. If you have a stubborn file or folder and don’t want to use any of the tricks here, you can just restart your computer. You should be able to delete, move, or rename the file as soon as Windows comes back up.
If the file is being locked by a startup program, you can boot to safe mode to delete it instead. Press the F8 key during the startup process and select Safe Mode to boot into safe mode. If you’re using Windows 8, you’ll have to use a different process to enter safe mode. Delete (or move) the file in safe mode and restart your computer.
There are a variety of other ways to delete locked files. For example, you could use a program to schedule a file deletion when you next restart your computer – the file will be automatically deleted when you reboot.