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 another 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. Sometimes, a program or background process may have finished with a file, but not unlocked it properly when it was done. In that case, you must unlock the stubborn file or folder in order to modify the file.
Note: Unlocking certain files and deleting them can cause problems with open programs. Don’t unlock and delete files that should remain locked, including Windows system files.
RELATED: How to Manage Open File Handles with PowerShell
Unlock a File with Process Explorer
You can unlock a file by using the excellent Process Explorer task manager. We’ve covered Process Explorer in detail before, so here we’ll just dive right into how to unlock a file. You won’t need to install it first—it’s a portable app—but you will need to run it with administrative privileges. You actually can do this from within Process Explorer by clicking the “File” menu and selecting “Show Details for All Processes.”
RELATED: Understanding Process Explorer
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 repeat this step to close the handle for each process.
You can now delete or modify the file normally.
IObit Unlocker
IObit Unlocker is a useful utility for unlocking files, and it’s free. It even puts a command for unlocking files right on the context menu. After you install the program, you can right-click a stubborn file or folder and select “IObit Unlocker” to open the app with that file selected.
You’ll see a list of processes that have locked the file or folder. You can quickly unlock the file by clicking the “Unlock” button. This method unlocks the file while leaving the process running. Note that this may cause problems if a process expects exclusive access to a file.
You can also click the “Forced Mode” checkbox and then click “Unlock” to forcibly close whatever program is locking access to the file. You’ll lose any unsaved data in any program killed this way.
Once the file is unlocked, you can delete, move, or rename it normally. In fact, the IOBit Unlocker application has easy “Unlock & Delete”, “Unlock & Rename”, and “Unlock & Move” options. Just click the arrow to the right of the “Unlock” button.
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 try restarting your computer. You should be able to delete, move, or rename the file as soon as Windows comes back up.
RELATED: Three Ways to Access the Windows 10 and 8 Boot Options Menu
If the file is being locked by a startup program, you can boot to safe mode to delete it instead. If you’re on Windows 7, 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 access safe mode from the boot options menu. 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. But we’ve found it much easier using one of the methods we’ve detailed here.