How To Force Delete A File in Windows 10 Or 11

Now and again, anomalies occur within Windows to prevent file or folder deletion or renaming. Every operating system in existence experiences some or another glitch from time to time. So, we will show you how to force delete a file in Windows quickly and easily.

The easiest way to force delete a file in Windows is by deleting it using the del /f command in the Command Prompt with administrator privileges. Another way is to gain ownership back. If all fails, you need a third-party application like LockHunter.

a mouse pointer selecting delete from a menu

I’m guessing by this stage, you’ve tried deleting a file, and it won’t budge. It’s not only frustrating but a little concerning at the same time.

You may also notice that the very same file likely cannot be moved, renamed, deleted, or altered in any way. It’s the same thing when trying to modify the file attributes.

But don’t worry, I will guide you through a robust set of methods to get rid of those pesky files for good.

Important: Please backup your files before deleting anything. At the very least, create a second copy of your files or folders into a zip file and move them elsewhere.

How you would normally delete a file

There are a few ways you can delete files in Windows. And I’m sure you have your go-to method.

how to delete a file in windows explorer

But here is a short mention of a few different ways:

  1. Right-click on the file in Windows File Explorer and left-clicking on delete.
  2. Same as method one, while holding down the Shift key to bypass the recycle bin and get rid of it completely the first time.
  3. By selecting it in Windows Files Explorer and pressing the Del key on your keyboard.
  4. Entering a command in the Command Prompt.
  5. Third-party software.

Causes as to why you may need to force delete a file

While this can be a complicated topic to discuss and deserves another article to cover the subject adequately, we will nonetheless touch on a few points.

The file is being used by another program

One of the more common causes is when a program that’s currently running is busy with the file.

For example, you’ve been editing a text file with Notepad and minimized Notepad. Finally, you decide that you don’t want the file any longer, so you open up Windows File Explorer and go to delete, only to find that you can’t.

Until you close Notepad enabling the file to be released, can you then go and delete it. Sometimes you will need to force quit a program first, in the event that it has frozen or is still running in the background.

So, to save you some time, try to close all applications until you have nothing open and attempt to delete the file(s) again.

If it works, you won’t need further steps to fix the problem.

You don’t have sufficient rights with your user account

This sometimes happens after transferring a drive from another computer with files left behind.

The file may have ownership rights for another user and was configured to have little control by users other than the original user account.

Whatever the reason was for your specific usage rights issue, you’ll need to get ownership back to fix the problem quickly.

To do this, add the following to your Registry:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

If you are unsure how to do this, you can download this file:

After you have downloaded it, unzip it and run it. Confirm that you wish to merge the file with your Windows Registry and confirm any further prompts.

Restart your computer before proceeding. We want to make sure that the new Registry data has taken effect.

When you right-click on the file while holding the Shift key on your keyboard, you should have an extra option in the context menu called Take Ownership.

With Windows 11, you will have to select Show more options first. After that, you will be able to left-click on Take Ownership.

To remove it, enter this into your Registry using the same method:

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\*\shell\runas]

[-HKEY_CLASSES_ROOT\Directory\shell\runas]

Once you have taken ownership of the file(s) or folder(s), attempt once more to delete the file.

If you don’t have any luck with this, don’t worry, there are more things to try.

Read-only file or folder attribute is enabled

how to remove read-only file attribute

File attributes are settings associated with your files and folders to tell your operating system how to handle them.

You can view them by right-clicking on your file or folder and selecting Properties.

Ensure the General tab is selected, and look to see if the Read-only checkbox is unchecked.

The file is corrupted or damaged

One reason a file may be corrupted is from a drive starting to go faulty, and it’s on the verge of failing or slowly losing integrity.

Another can be that the file gained errors once downloaded or transferred over your network or from the internet.

Either way, this isn’t a very nice situation, and you may need to restart your computer into safe mode or rely on third-party software to remove it.

Use a program called Crystal Disk to establish the health of your drives.

If your HDD or SSD is coming back with some errors, back up all your files immediately and install a new replacement drive.

It will only worsen you, and you don’t want to turn your computer on one day and discover everything is inaccessible.

Boot into safe mode

If your drives seem fine, the first thing to try is to boot into safe mode.

Tip: I recommend opening this article on your mobile to continue following the steps below after restarting your computer.

To do this:

  1. Open the Start Menu by clicking on the Windows Start icon.
  2. Click on the Power symbol to open some new options.
  3. Hold down Shift on your keyboard and left-click on Restart.
  4. After the computer restarts, click on Troubleshoot.
  5. Then click on Advanced Options.
  6. Then select Start Up Settings.
  7. Click Restart.
  8. Select Safe Mode with any additional options you may want. I recommend just staying with Enable Safe Mode.

Now try and delete your file.

Malicious software infection

an abstract representation of a virus or malicious software

Some harmful software made its way onto your machine and can hold specific files it needs to keep the infection present and in memory.

It could also send out information and perform other tasks using your computer.

If this is the case, I’d look for unwanted running processes and end them in the Task Manager.

Download and install anti-virus software and get a preboot scan completed.

The best free version I can recommend is Avast Antivirus.

After that, install Malwarebytes (free version) and run a scan to get rid of the rest of the unwanted software.

If this doesn’t help, try taking it to an expert, or perform a clean installation of Windows to make sure you are rid of anything bad.

Important: Backup all your emails, important files first, before doing this. And try not to hand onto .exe files that you don’t need.

Manually force delete a file using the command prompt

The delete command in the command prompt is a bit more technical but has turned out to be a lifesaver for me on many occasions over the years.

Follow these steps to force delete a file manually:

Run App with CMD Command Entered
  1. Open the Run command window by right-clicking on the Start Menu icon and selecting Run.
  2. Type in cmd into the text block of the Run command window.
  3. Type in cd\ followed by the path of your file. You can look at it in Windows Explorer to find the path. It will be at the top of File Explorer and you can right click within that bar to copy the path to text if you want (shown below). Make sure you include the whole command in double quotes if you have any spaces in the filename or anywhere in the path.
  4. Then type in del /f follwed by the filename and extension you want to delete and hit enter.
how to copy the file path of a file
How to copy a file path of a file
example of del /f command in command prompt to force delete a file
An example file being used with the del /f command

Your file should be gone after this. If it comes back with an ownership issue, go back to the earlier part of this article to install the take ownership feature and try again.

You can do the same thing with folders. However, you’ll need to substitute:

del /f

with

rmdir /q /s

Use third party software to force delete a file

Download and install LockHunter. It’s a free tool and works very well when all else fails, or you are looking for the least complicated fix.

Doing it this way eliminates the need to do anything technical and allows you to force delete files and folders using a graphical user interface.

It’s a foolproof unlocker and will work with most versions of Windows.

Conclusion

I hope that solves your locked files and folders issues and you can get on with your important work on your computer.

Using the Command Prompt is a bit of a learning curve initially, but it will prove to be a valuable tool in the future for more things than just force deleting files.