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
- Press
Win + R, typeresmonand press Enter - Open the CPU tab
- Expand Associated Handles
- Type the file or folder name in the search box on the right. Partial names work
- Note the Image (process) and PID in the results
- 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.
- Retry the delete, move or rename.
Method B: PowerToys File Locksmith
- Install PowerToys:
winget install Microsoft.PowerToys --source winget - In PowerToys Settings, enable File Locksmith.
- Right-click the locked file or folder in Explorer, then choose Show more options → What’s using this file?
- 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
- Close any terminal windows whose prompt is inside the folder.
- Restart Explorer: Task Manager → Windows Explorer → Restart.
- Pause OneDrive sync (tray icon → Pause syncing) and retry.
- Temporarily disable real-time antivirus scanning, only if you trust the file.
- Reboot and delete the file before anything else starts.
- Last resort: boot into Safe Mode, or into the Windows Recovery Environment command prompt, and delete it with
delorrmdir /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.
Leave A Comment?