If you’ve ever found yourself attempting to delete or rename a file in Windows, only to be met with the frustrating message, “The action can’t be completed because the file is open in another program,” you’re not alone. This persistent error has been a part of the Windows experience for decades, and it doesn’t always convey the full story. Recently, Mark Russinovich, Azure CTO and Technical Fellow at Microsoft, shed light on this issue, revealing insights that date back to his own experiences in the 1990s when he first encountered this conundrum. To address it, he developed two specialized tools.
What does ‘file in use’ error mean in Windows?
At its core, the ‘file in use’ error indicates that a file is currently being accessed by a program. More technically, every time a program opens a file, Windows generates a file handle, which serves as a reference for tracking which program has access to which file at any given moment. This mechanism is crucial; Windows prevents the deletion or renaming of a file while an open handle exists to avoid potential data corruption.
Typically, when an application is closed, Windows releases these handles. However, the reality is that simply closing an application doesn’t always guarantee that all handles are released.
Why closing an app does not always release the file
Russinovich identifies three prevalent reasons why a file may remain locked even after you believe you’ve closed the associated program:
- Antivirus Interference: Your antivirus software may be scanning the file. During a scan, it opens a file handle at the system level, meaning that even if applications like Media Player or Word have closed, the antivirus could still be holding the file open in the background.
- Network References: If the file is being accessed by another device on your network, that remote process may still maintain a handle to the file.
- DLL Scenarios: In more complex situations, if the file is loaded as a Dynamic Link Library (DLL), it won’t appear as an open file handle. Instead, it exists as an in-memory reference, making it invisible to standard tools. To release this lock, the entire application that has it mapped must be terminated.
How to find which process is responsible for “file in use” error
To tackle the ‘file in use’ error, Russinovich created a command-line tool named Handle, which is part of the Sysinternals suite—an advanced set of Windows utilities now maintained by Microsoft. Running Handle from an administrator command prompt reveals every open file handle on the system, complete with the process name and ID responsible for each handle. Users can search for a specific file name to pinpoint the issue directly.
For those who prefer a graphical interface, Process Explorer, also developed by Russinovich, serves as a companion tool. By pressing Ctrl + Shift + F within Process Explorer, users can access the Find Handle or DLL search window. Entering the name of the locked file will reveal which process has it open, allowing users to either close the handle or terminate the process before attempting to delete the file again.
Sysinternals in PowerToys, the easier option for regular users
For users who find the command line daunting, Microsoft offers a more user-friendly solution. As reported by Windows Latest in 2024, Mark Russinovich suggested integrating Sysinternals tools into PowerToys, a proposal that has gained traction. PowerToys currently features File Locksmith, a tool that enables users to right-click a file, select ‘Unlock with File Locksmith,’ and instantly view a list of processes holding that file open. From this interface, users can terminate the offending process and delete the file without delving into the command line.
Workaround that Microsoft recommends to fix “file in use” error
In addition to these tools, Russinovich offers a practical workaround for those unable to immediately terminate the process holding a file. Instead of deleting the file, users can rename it. Windows allows renaming a file even when it is open in certain contexts. After renaming, a new copy of the file can be placed in the same location, allowing any process that requires it to access the new version. The renamed original can then be deleted once the process holding it releases its handle.
This long-standing issue has been woven into the fabric of Windows since its inception. With Microsoft’s acknowledgment and the provision of practical solutions, users can navigate these challenges with greater ease. Russinovich’s dedication to developing tools that reveal what Windows often conceals speaks volumes about the ongoing relevance of these utilities in today’s computing landscape.