ERROR

How to Fix Windows Error 0x80070020 (File In Use)

Quick Fix Summary

TL;DR

Stop the process holding the file lock using Task Manager or the Resource Monitor.

Error 0x80070020 is a sharing violation indicating a file or folder is locked by another process, preventing access. This is a common Windows system or application conflict.

Diagnosis & Causes

  • Antivirus or security software scanning the file.
  • Another application or service has an open handle.
  • A stalled Windows Update process.
  • File system corruption or pending rename/delete.
  • A background system process like Search Indexer.
  • Recovery Steps

    1

    Step 1: Identify and Terminate the Locking Process

    Use Resource Monitor to pinpoint the exact process with the file handle and end it.

    bash
    resmon
    Navigate to the 'CPU' tab -> 'Associated Handles' -> Search for the locked file path.
    Right-click the identified process -> 'End Process'.
    2

    Step 2: Stop and Restart Critical Windows Services

    Restart services that commonly cause file locks, especially during updates or installations.

    bash
    net stop wuauserv
    net stop cryptSvc
    net stop bits
    net stop msiserver
    net start wuauserv
    net start cryptSvc
    net start bits
    net start msiserver
    3

    Step 3: Clear the SoftwareDistribution Cache

    Corrupted Windows Update cache files are a prime culprit. Rename the folder to force a rebuild.

    bash
    net stop wuauserv
    net stop bits
    ren C:\Windows\SoftwareDistribution SoftwareDistribution.old
    net start wuauserv
    net start bits
    4

    Step 4: Boot into Safe Mode and Perform the Action

    A clean boot state minimizes running processes, allowing you to delete or modify the locked file.

    bash
    msconfig
    Go to the 'Boot' tab -> Check 'Safe boot' -> Select 'Minimal' -> Apply/OK -> Restart.
    5

    Step 5: Use the Command Line to Take Ownership and Force Delete

    For stubborn system files, use an elevated command prompt to forcibly change ownership and delete.

    bash
    takeown /f "C:\Path\To\LockedFile.exe" /a
    icacls "C:\Path\To\LockedFile.exe" /grant administrators:F
    del /f "C:\Path\To\LockedFile.exe"
    6

    Step 6: Utilize Sysinternals Process Explorer (Advanced)

    Process Explorer provides superior handle and DLL viewing. Use 'Find Handle or DLL' (Ctrl+F).

    bash
    Download Process Explorer from Microsoft.
    Run as Administrator -> Press Ctrl+F -> Search for the file name.
    Right-click the process -> 'Close Handle'.

    Architect's Pro Tip

    "For persistent locks during Windows Updates, temporarily disable your third-party antivirus real-time protection before attempting the update. It's the most common silent blocker."

    Frequently Asked Questions

    Can I fix error 0x80070020 without restarting my computer?

    Yes, in most cases. Using Resource Monitor or Process Explorer to find and end the specific locking process is the fastest non-reboot solution.

    Why does this error keep happening with Windows Update?

    The Windows Update service (wuauserv), BITS, or the Cryptographic service can get stuck holding locks on files in the SoftwareDistribution folder. Stopping these services and clearing the cache usually resolves it.

    Is it safe to delete files causing the 0x80070020 error?

    Only if you have identified them as non-critical (e.g., temporary update files, a user document). Never force-delete core Windows system files (e.g., from System32) without absolute certainty.

    Related Windows Guides