Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Facebook Twitter Instagram
Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Tech News Today
Home » Windows

How to Force Delete a File? 5 Simple Ways

Abhishek SilwalBy Abhishek SilwalApril 4, 2023
how to force delete a file

The process of deleting a file in Windows is simple and straightforward. You need to select a file and then press delete or right-click on the file and select Delete to remove the file. You can also use the Shift + Del shortcut to force Windows to delete the file without sending it to the Recycle bin.

However, there are some situations where you can’t delete a file at all, and the usual methods will result in some error messages. In such cases, you need to rely on the command-line interfaces to force the deletion or resolve the root of the problem causing such issues.

Table of Contents

  • Through Command Line Interface
  • By Replacing the File
  • By Booting into Safe Mode
  • Modifying Permissions
  • Using Robocopy to Mirror an Empty Folder

Through Command Line Interface

You can also use the command-line interface tools like Command Prompt and PowerShell to forcefully delete a file in Windows.

However, the commands can’t remove hidden or read-only files on their own, so you need to use the force parameters (/f or -force) alongside in such cases.

On Command Prompt

  1. Open Run by pressing Windows key + R.
  2. Type cmd and press Ctrl + Shift + Enter to open the Elevated Command Prompt.
  3. Type the command del /f /q “Full path of file” and press Enter to force delete the file.
    For instance, if you wish to delete File1.txt inside D:\Folder, you need to enter del /f /q “D:\Folder\File1.txt”
    cmd-force-delete-file

On PowerShell

  1. Open Run.
  2. Type powershell and press Ctrl + Shift + Enter to open Windows PowerShell as admin.
  3. Use the cmdlet Remove-Item -Path “Full path of file” -Force to delete the file. E.g., Remove-Item -Path “D:\Folder\File1.txt” -Force
    powershell-force-delete-file

By Replacing the File

Another way you can forcefully delete a file is by replacing the file. This way, you can delete some files that you couldn’t by using the above methods. Also, keep in mind that the file won’t go to the Recycle bin as well.

  1. Create another file in another location with the same name as the file you want to delete.
  2. Copy or move the new file to the folder containing the old file.
  3. Accept the prompts when it asks you if you wish to overwrite the file.
    replace-the-file-in-the-destination
  4. Then, try deleting the file the normal way.

By Booting into Safe Mode

If some application is currently using or holding a file, trying to delete the file results in an error message that says, “The action can’t be completed because the file is open in another program.”

You can try looking for the application that is using the files, close it or end it from the Task Manager and then delete the file. If you don’t know which app it is, restart your PC and delete the file.

But if the application is a startup process, restarting may not make the process release its hold on the file. You will need to boot in safe mode to be able to remove the file in this scenario.

  1. Open the Start menu and click on the power button. Press and hold the Shift key and then click Restart. It will load the Advanced Startup options.
  2. Here, select Troubleshoot > Advanced options > Startup Settings > Restart.
    restart button in startup settings in windows re
  3. After the reboot, you’ll see the startup settings again. Press F4 or 4.
  4. Now you can use any method to delete the file after logging in to a user account.

Modifying Permissions

You can only delete a file if your current user account or user group has full ACL permissions for the file. If not, you’ll get an error message like “You need permission to perform this action.”

You need to change the security settings to be able to delete the file.

  1. Log in to an Administrator account.
  2. Right-click on the file and select Properties.
  3. Go to the Security tab.
    security-tab-advanced
  4. Click on Advanced and select Change next to Owner.
  5. Type Administrators or the user account name and hit Check Names. The name should now show “Computer Name”\“user name” or “Computer Name”\Administrators.
    change-owner-administrators-check-names
  6. Click OK > OK.
  7. Click Edit and select the user account.
  8. Check Full control and click OK > OK.
    full-control-allow-permission
  9. If the account is not there,
    • Select Add.
    • Type Administrators or the user account name and hit Check Names. Then, click OK.
    • Check Full control and click OK > OK.
  10. Now delete the file the normal way or through the Shift + Del hotkey.

Using Robocopy to Mirror an Empty Folder

In some rare cases, you may get files that are not being used by another process but are particularly difficult to remove. For instance, if somehow a filename contains a space at the end, Windows will show the file but treat it as if it’s not there. There are also other scenarios where the same happens. 

This file won’t have any security information, and you can’t modify or delete it. If you try to do so, you’ll get the error message: “Could not find this item.”

The easiest way to forcefully delete the file in such cases is to make it the only file inside a folder and then mirror an empty folder to this one.

  1. First, move all the folders and files from the directory containing the file somewhere else. For example, if you wish to remove D:\Folder\File1 .txt (notice the space at the end), move all contents inside the D:\Folder folder to another location.
  2. Then, create a new folder anywhere. In this case, inside D: as Empty, so its path is D:\Empty. Don’t put anything inside the folder.
  3. Open the Command Prompt.
  4. Type robocopy “New empty folder’s path” “Path of the file’s folder” /mir and press Enter.
    Make sure to replace all the file paths appropriately. In this example, it would be robocopy “D:\Empty” “D:\Folder” /mir
    robocopy-mirror-empty-folder

Note: If you encounter any error messages, such as 0x80070570: The file or directory is corrupted and unreadable, it represents the drive sectors containing the file is corrupted. You can try running chkdsk before attempting to delete the file in such cases.

how-to
Abhishek Silwal
  • LinkedIn

Abhishek Silwal is an Electronics Engineer and a technical writer at TechNewsToday. He specializes in troubleshooting a wide range of computer-related issues. His educational background in Electronics Engineering has given him a solid foundation in understanding of computers. He is also proficient in several programming languages and has worked on various robotics projects. Even in his early days, he used to tinker with various computer components, both hardware, and software, to satiate his curiosity. This experience has given him a breadth of experience that goes beyond his educational qualification. Abhishek has been writing articles on dealing with varieties of technical issues and performing specific tasks, especially on a Windows machine. He strives to create comprehensive guides on fixing many system and hardware issues and help others solve their problems. You can contact him at abhisheksilwal@technewtoday.com

Related Posts

how to turn off hardware acceleration

How to Turn Off Hardware Acceleration

September 22, 2023
what happens if you turn off your computer during an update

What Happens if You Turn Off Your Computer During an Update?

September 18, 2023
How to Disable Integrated Graphics

How to Disable Integrated Graphics?

September 16, 2023
System Restore Stuck

How To Fix Windows Stuck on System Restore

September 16, 2023
startup-repair-couldn't-repair-your-pc

How To Fix “Startup Repair Couldn’t Repair Your PC”

September 13, 2023
how to free up ram

How to Free Up Memory

August 4, 2023
Add A Comment

Leave A Reply Cancel Reply

Latest Posts
how to turn off hardware acceleration

How to Turn Off Hardware Acceleration

September 22, 2023
motherboard chipset

Understanding Motherboard Chipset and Its Importance

September 20, 2023
Naval-Warfare-Games

Best Naval Warfare Games

September 18, 2023
You may also like
printer-not-printing

How to Fix a Printer That’s Not Printing

September 26, 2023
Share Location With Friends and Family

Share Location With Friends and Family (iPhone and Android)

September 18, 2023
how-to-print-without-a-printer

How to Print Without a Printer

September 18, 2023
Recommended
Cookie Clicker Garden Guide

Cookie Clicker Garden Guide to Unlocking Every Seed

September 26, 2021
monitor no signal

Computer Turns On But Monitor Says No Signal (9 Ways To Fix)

November 10, 2022
Facebook Twitter Pinterest
  • Home
  • About Us
  • Our Team
  • Editorial Guidelines
  • Privacy Policy
  • Affiliate Disclosure
© 2023 TechNewsToday, editor@technewstoday.com | Tech Central Pvt. Ltd.

Type above and press Enter to search. Press Esc to cancel.