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.
You 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.
Next, click the Find menu and select Find Handle or DLL. (Or press Ctrl+F.)
Search for the name of the locked file or folder.
Select the locked file or folder and you’ll see the handle in the details box at the bottom of the Process Explorer window.
Right-click the handle and select Close Handle. If multiple processes are listed in the search window, you’ll have to remove to repeat this process to close the handle for each process.
You can now delete or modify the file normally.
Unlocker 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.)
WARNING: Be very, very, very careful with the Unlocker site. They have very confusing and tricky ads, and their installer bundles crapware. Instead of using Unlocker, we recommend using Process Explorer instead.
You’ll see a list of processes that have locked the file or folder. You can kill the processes or quickly unlock the file while leaving the processes running. Note that this may cause problems if a process expects exclusive access to a file.
Once the file is unlocked, you can delete, move, or rename it normally.
Restart Your Computer
Generally, 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 or 10, 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.