Usually it's easy to delete files, Indeed, it's much more common to delete a file by accident. However, there are some files which can't be deleted: they're in use by an application, by Windows or for another reason. Here are five ways of deleting or renaming files which are in use.
When a file is classified as "in use" by Windows, it is typically still open by another process, which could be making changes to it. In many cases, Windows even points you directly to the program in question in the error message, allowing you to simply close it and try again. Typically though, this isn't the case.
If the file is displayed as "in use" but there's no indication of which app is using it, you have two options to proceed: You can either use the handy tool Unlocker, which integrates itself into the Windows UI seamlessly, or delete or rename files over the command prompt without any third party software.
Here are the methods we'd try - in this order - to delete or rename a locked file.
1. Close Windows Explorer
If you've closed down all the obvious apps which could be using the file and you still can't delete it, it's probably because Windows Explorer (File Explorer in later versions) is accessing the file, perhaps to display a preview.
You could move all other files in the folder to a temporary folder and then delete the folder that contains the immovable file, but if this still doesn't work, try closing Windows Explorer or File Explorer.
If they won't close, you can force them by using Task Manager (right-click on the taskbar and choose Task Manager).
Now look through the list of running applications for Windows Explorer (File Explorer is still called Windows Explorer here!), right-click on it and choose End Task. You'll then have to restart it, since Explorer is also responsible for the start menu and the task bar. To do that, click File, Run... and type Explorer.exe and press Enter.
2. Change the file extension
Sometimes this is the simplest way to delete a file that refuses to budge using the Delete key. If you have file called birthday.mp3, select it in Windows Explorer, press F2 and change the extension - the .mp3 - to something else such as .txt.
You'll have to enable file extensions first, though, since Windows defaults to hiding extensions for known file types. To show extensions in Windows 8 onwards, click on the View tab and tick the 'File name extensions' box.
In previous versions, including Windows 7, search for 'folder options' in the Start menu. Click on it and a window will appear. Scroll down and untick the box for "Hide extensions for known file types" and click OK.
3. Use the Command Prompt
Yet another method is to use the Command Prompt. You'll find this in your Start menu, or Start Screen. Just search for it, click on it and a black window will open. Or, press the Windows key and R to bring up the Run.. box and type cmd.exe and press Enter.
Type “del” or “ren” into the prompt, depending on whether you wish to delete or rename the file, and hit space once.
Drag and drop the locked file with your mouse into the command prompt. If you wish to rename the file, you need to append the new name for it at the end of the command (with the file extension). This is shown in the image above.
You will need to close the Windows Explorer to release the lock on all files in use (as per our tip above). To do so, first close all Explorer windows and open up Task Manager with the key combination Ctrl-Shift-Esc. Switch to the Processes tab.
Look for the entry explorer.exe, select it and click on End Task. If there are multiple entries called explorer.exe, you must close them as well.
Switch over to your command windows and hit Enter to activate your prepared command. If everything has gone well, your file should be deleted or renamed without any hassle.
To bring your Start menu and taskbar back, click back on Task Manager and choose New Task (Run) from the File menu and type explorer into the empty field. Press Enter to restore the Windows interface.
4. Use a third-party deletion tool
Plenty of free utilities can clean up troublesome files, including those that can't be deleted. They tend to create a script which runs when Windows boots up at a time before any restrictions are placed on the file preventing it being deleted. They include File Assassin and ECMO UnlockIT (formerly called MoveOnBoot).
Also, you can try Long Path Tool which is a favourite for a lot of experienced PC users.
Another method of finding out which program is using particular files is by using the freeware Unlocker. Download the tool and install it. This adds an option in the context menu called “Unlocker” that allows you to get an overview of all the processes that are currently trying to access this file. Choose an operation from the drop-down menu and click on “Unlock all” to close all so-called “Handles” that are blocking access to the file and to apply your operation of choice.
A similar free tool, but with a steeper learning curve, is Microsoft's own Process Explorer.
5. Boot into Windows Safe Mode
Another option is to restart your PC in safe mode. In Windows 7 or earlier press F8 when the computer is starting up until you see the boot menu. Choose Safe Mode and a cut-down Windows will load. You can try deleting the file in Windows Explorer or File Explorer. Here's how to boot into safe mode in Windows 10.
Further reading: What to do when Windows Explorer doesn't refresh
Click here for the best Microsoft voucher codes.