How to find and release a File Locked by another process in Windows 11

Configurare noua (How To)

Situatie

Symptoms

  • “The action can’t be completed because the file is open in another program”
  • “The process cannot access the file because it is being used by another process”
  • A folder can’t be renamed, moved or deleted, even though nothing seems to be using it
    • A background process holds a handle on the file (an Office instance, a media player, a backup agent)
    • Antivirus or OneDrive is scanning or syncing the file
    • A Command Prompt, PowerShell or WSL window has the folder as its current directory
    • Explorer’s preview pane or a shell extension (thumbnail, preview handler) is reading the file

Solutie

Method A: Resource monitor

  1. Press Win + R, type resmon and press Enter
  2. Open the CPU tab
  3. Expand Associated Handles
  4. Type the file or folder name in the search box on the right. Partial names work
  5. Note the Image (process) and PID in the results
  6. Close that program normally. If it won’t close, right-click the process in the top list and choose End Process. Save your work first.
  7. Retry the delete, move or rename.

Method B: PowerToys File Locksmith

  1. Install PowerToys: winget install Microsoft.PowerToys --source winget
  2. In PowerToys Settings, enable File Locksmith.
  3. Right-click the locked file or folder in Explorer, then choose Show more options → What’s using this file?
  4. The window lists the processes holding the file. You can end them from there.

Method C: PowerShell (for locked DLLs and modules)

This only finds processes that have the file loaded as a module, not every kind of handle:

powershell
Get-Process | Where-Object {
  $_.Modules.FileName -like "*yourfile.dll*"
} | Select-Object Name, Id

Run PowerShell as Administrator, otherwise some processes can’t be inspected.

If nothing shows up

  1. Close any terminal windows whose prompt is inside the folder.
  2. Restart Explorer: Task Manager → Windows Explorer → Restart.
  3. Pause OneDrive sync (tray icon → Pause syncing) and retry.
  4. Temporarily disable real-time antivirus scanning, only if you trust the file.
  5. Reboot and delete the file before anything else starts.
  6. Last resort: boot into Safe Mode, or into the Windows Recovery Environment command prompt, and delete it with del or rmdir /s.

Verification

  • The delete or rename completes without an error.
  • Searching the filename in Resource Monitor returns no handles.

Notes

  • Killing system processes can crash the session. Only end processes you recognize.
  • Never force-delete a file that a database or backup job is writing to. Stop the service first.

Tip solutie

Permanent

Voteaza

(0 din 1 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?