How to Force Windows to Delete a File

This article was updated in August 2018.

Sometimes, for whatever reason, Windows will become convinced a given file is in use by a program and prevent it from being deleted, moved or renamed. This locking up of files is incredibly frustrating, especially when you know the file is not, in fact, being used. Here are two ways to get around that issue.

1. Force delete using Windows

First, open the command prompt. To do this, start by opening the Start menu (Windows key), typing run, and hitting Enter. In the dialogue that appears, type cmd and hit Enter again.

--ADVERTISEMENT--

With the command prompt open, enter del /f filename, where filename is the name of the file or files (you can specify multiple files using commas) you want to delete. There are more details on advanced deletion methods here.

Note that to delete the file you’ll need to either include the full path of the file where you replace filename, or navigate to the folder it is contained in using cd folderpath, and then run the del command. See the image below for an example of the latter method.

2. Use Unlocker

Unlocker is a free program that simplifies the deletion of locked files. It adds a context menu item to Windows Explorer, and can be activated by right-clicking. It also allows the user to rename or move a locked file.

Adam is SitePoint's head of newsletters, who mainly writes Versioning, a daily newsletter covering everything new and interesting in the world of web development. He has a beard and will talk to you about beer and Star Wars, if you let him.