How to forcibly remove a file or folder in Windows 11

Sometimes you try to delete a file or folder, and it fails. You then get the message that the file is in use.

There are several reasons why a file or folder cannot be deleted. For example, the file is in use by another process. It also happens regularly that the file cannot be deleted because it has been placed in a location where the logged-on user has restricted rights.

This can be the case on a network location and an external medium such as an external hard disk or a USB stick. This is usually a medium protected against writing by rights or by a physical button on the medium itself.

So there are a few things you should check beforehand before attempting to forcibly delete the file.

  • Check whether the file is in use.
  • Check your PC’s disk space and ensure the medium is not encrypted.
  • Is the location where the file resides a “read-only” location.
  • Is the recycle bin full?
  • Is the file in use by malware. Check this with Malwarebytes.

If you have checked all this, then you can use the commands below to try to forcibly delete the file. Some technical knowledge required.

How to forcibly remove a file or folder in Windows 11

Delete a file directly without the recycle bin

To begin with, you can try to delete the file by skipping and moving it to the Recycle Bin. In Windows, a file is first moved to the Recycle Bin and can still be deleted from there. So by skipping this step, you may be able to delete the file.

Click on the file. Then press the SHIFT + DELETE button on your keyboard to delete the file directly.

Terminate the process first and then delete it

The second way to try to forcefully close a file is to first close the process with “taskkill” and then delete it.

Click on the Start button and search for “command prompt”. Then, right-click on it and click on “Run as Administrator”.

Run command prompt as administrator

In the Command Prompt type:

taskkill /f /im filename.exe

The process will now be forcibly closed. First, change “filename.exe” with the file you are trying to close.

Terminate a process using taskkill

If it says “SUCCESS: The process “..” with PID … has been terminated”. Go da to the location of the file and try to delete it again.

Forced removal of file or folder via Command Prompt

You can also use the “DEL” command to add an argument to forcefully delete a file. Here’s how it works.

Click the Start button and search for “Command Prompt”. Then, right-click on it and click “Run as Administrator”.

Run command prompt as administrator

Go to the location through the Command Prompt where the file or folder you want to forcibly delete is located.

Force Delete File

In the Command Prompt type:

DEL /F /Q /A "path-to-file-name.exe"

Replace the path and the executable file. Now check if you can delete the file.

Force Delete Folder

If you want to delete a folder, then enter the following command:

RD /S /Q "folder-location"

Replace the path. Now check if you can delete the file.

Otherwise, try rebooting your PC if you have not already tried this.

I hope this has helped you. Thanks for reading!

Leave a Comment

Your email address will not be published.

Scroll to Top