How To Delete Locked and In-Use Files in Windows Operating System

Trying to delete a file in Windows and getting an error message that the file is in use or locked can be very frustrating. However, there are several methods you can use to force delete these stubborn files. As an IT professional with over 10 years of experience, I will explain the most effective techniques to delete locked and in-use files in Windows.

Understanding Locked and In-Use Files

When a program or process opens a file, it places a lock on the file to prevent other programs or users from modifying it while it is in use. This is an important mechanism to ensure file integrity.

However, sometimes programs fail to properly close files after use, leaving them in a locked or in-use state. You may also encounter locked files if a program crashes while the file is open.

Attempting to delete or rename these locked files results in error messages like:

  • “File in use. Close the file and try again.”
  • “Access denied. The file is currently in use.”
  • “Sharing violation. The file is currently in use.”

To delete these locked files, you first need to determine what process has them locked and close that process.

Method 1: Use Task Manager to Close Locking Process

The easiest way to delete a locked file is to use Task Manager to close the process that has the file locked. Here is how:

  1. Open Task Manager (Ctrl+Shift+Esc)
  2. Go to the “Details” tab
  3. Right click on columns and enable the “PID” column
  4. Search for the locked file name
  5. Identify the Process ID (PID) of the process locking the file
  6. Right click on that process and choose “End task”
  7. The file should now be unlocked – delete it quickly!

This method works well for unlocking files locked by applications. However, it won’t work if the file is locked by Windows system processes.

Method 2: Unlock File Using Unlocker Utility

For system locked files, specialized unlocker utilities like “Unlocker” work very well. Follow these steps:

  1. Download and install Unlocker
  2. Right click on the locked file and choose “Unlocker” > “Delete/Rename/Move”
  3. Unlocker will display the process locking the file
  4. Click “Unlock All” and then “Yes” to unlock the file
  5. Delete the file immediately after it unlocks

I recommend Unlocker as it easily integrates with Windows explorer, making it very convenient to use.

Method 3: Unlock File from Command Prompt

You can also unlock files from an elevated Command Prompt window using the “DEL” command.

Follow these steps:

  1. Open elevated Command Prompt
  2. Navigate to the folder containing the locked file
  3. Type the command: DEL /F /A filename (Replace filename with actual filename)
  4. Press Enter – the file will be deleted on next reboot

This method force deletes the file and schedules it to be permanently deleted on next system restart.

Method 4: Delete File in Safe Mode

If the above methods don’t work, booting into Safe Mode is another option. Since most processes and services don’t start in Safe Mode, files are easily unlocked.

To delete locked files in Safe Mode:

  1. Reboot and press F8 to open Advanced Boot Options
  2. Choose “Safe Mode”
  3. Log in with admin account
  4. Navigate to file location and delete the file
  5. Restart computer normally

This should successfully delete the previously locked system file.

Preventing Locked Files

To avoid dealing with locked files, its best to follow these practices:

  • Always properly close applications after use
  • Avoid force shutting down computer
  • Use a file locker software if needing to protect files
  • Schedule regular system restarts
  • Keep software and drivers updated

Following these tips will minimize instances of lock files on your system.

Conclusion

While locked and in-use files can occasionally cause problems, there are several effective methods to force delete them in Windows. Using Task Manager, unlocker utilities, Command Prompt, and Safe Mode, you can easily regain control of these stuck files. Implementing best practices can also reduce future occurrences.