Remove stubborn files

Author: Roger Morrison
Date Of Creation: 25 September 2021
Update Date: 9 May 2024
Anonim
Force Delete a File That Cannot Be Deleted Windows 10
Video: Force Delete a File That Cannot Be Deleted Windows 10

Content

If you are trying to delete a file but the operating system does not allow it, it is probably because another program is trying to use the file at the same time. This can also happen if you don't see a program running. Deleting these files is usually a matter of forcibly closing the program using the file, if necessary. Be careful with this; deleting the wrong file can have unpleasant consequences for your system.

To step

Method 1 of 2: Windows

  1. Close all open programs and try to delete the file again. The most common reason that a file cannot be deleted is because a program is using the file. Close all open programs and try to delete the file again.
    • If the file still cannot be deleted, read on.
  2. Open the command window. If you cannot delete a file because it is in use by another program, the quickest way to delete it is through the command prompt.
    • Press Windows key + R and type cmd to open the command window.
  3. Navigate to the location of the file you want to delete. You will see the path to the file in the Explorer window. Type cd C: path to file and hit Enter. Replace C: by the actual drive letter and path to file by the path to the folder.
  4. Type.dirand hit Enter for a list of files. Note the exact name and extension of the file you want to delete.
  5. Press Ctrl + Shift + Esc to open Task Manager. Force Windows Explorer to exit.
  6. Select the tab.Processes and selectexplorer.exeor "Windows Explorer". Click the End Task button. This will close the Desktop, leaving only the Command Window and other open windows.
  7. Return to the Command window again and type.del filename.extension. This will try to delete the specified file. Make sure to include the full name and extension of the file.
  8. Delete the folder of the file if you cannot delete the file yet. Sometimes it is possible to delete a file by deleting the folder it is in. Keep in mind that if you delete a folder, all content is deleted. Type rmdir / s directoryName and hit Enter.
  9. If you cannot delete the file, try to boot in safe mode. If the file still cannot be deleted, you may need to boot in safe mode. This will only load essential processes, hopefully allowing you to delete the file.
    • Restart your computer and quickly press F8 until the Advanced Boot menu appears.
    • Select Safe mode with command prompt from the menu. Windows will load the essential files and take you straight to the Command Prompt.
    • Use the following steps to navigate to your file and try to delete it again.
  10. Try to delete the file using the short name of the file. Sometimes strange characters can make file deletion problematic. Using the "short name" (suitable for DOS) of the file can sometimes help.
    • Navigate to the directory of the file and type dir / x.
    • Write down the short name of the file (eg. FILENA ~ 1.XYZ).
    • Type del FILENA ~ 1.XYZ and hit Enter.

Troubleshooting

  1. Use a Linux Live CD to access your files. This is a simplified operating system, usually Linux, that you can boot from a CD. Using a Linux Live CD, you can access all of your files without booting into Windows, meaning no Windows processes blocking the deletion.
    • Click here for instructions on how to download, create and boot a Linux Live CD.
    • After booting into the Linux environment, you can access the hard drive and delete any file, no matter how stubborn. Always be careful when deleting system files.
  2. Check your disk for errors. If you receive an error message that your hard drive may be damaged, the corruption may make your file undelete. If so, you should try to recover the drive before you can delete the file.
    • Open the Command window, type chkdsk / r and hit Enter.
    • Restart your computer when prompted and give permission to check your hard drive. The chkdsk process can take several hours. An attempt is made to automatically fix any errors it encountered, but the presence of errors probably means that the drive will fail again in the near future.
  3. Take ownership of tricky files. Sometimes files are created that you do not have rights to delete. To delete these files, you must take ownership of the file.
    • Boot in safe mode.
    • Right-click on the file or folder you want to delete.
    • Click the Security tab.
    • Click Advanced and then Owner.
    • Check the box next to your username for "Full Control".
    • Click Apply and then try to delete the file or folder again.

Method 2 of 2: Mac OS X

  1. Find out which program is preventing you from deleting the file. The most common reason a file cannot be deleted in OS X is because a program is using the file. This process will determine which program is holding the file hostage.
    • Open the "Terminal" in the Utilities folder.
    • Type lsof and drag the file you want to delete into the terminal window. Press Return to view the program that is using the file.
    • watch the COMMAND and PID columns. COMMAND is the name of the program blocking the file, and PID can help you close it.
  2. If possible, close the program normally. When the program is open and visible, close it according to the normal procedure. If the program refuses to close, you can try to force it to close.
    • You can find the "Activity View" in the Utilities folder for an overview of the running processes. Use the PID column in Activity Monitor to find out if the PID of the process (discovered using the Terminal), matches this. Select the process you want to close and click "Close process".
  3. Use the "Safely Empty Trash" command when emptying the Trash. Attempts to unlock locked files placed in the Recycle Bin before deleting them. Use this option if you receive messages about locked files when you try to empty the Trash.
    • Hold down the Option key when you right-click the Trash to empty it safely. This will delete most of the files that are locked.

Warnings

  • Always be careful when deleting files that are locked as this usually occurs when trying to delete a system file. Deleting the wrong files can make your system unusable until you reinstall the operating system.