How to find out which process blocks a file or folder

How to find out which process blocks a file or folder

How many times does it happen that we receive an error message when we want to delete a file or folder? Often the error message reads:

The action cannot be completed because the folder is open in another program

Let’s see how to figure out which process blocks the resource to be deleted

We use resource monitoring

Resource Monitor is present as far back as Windows 7 to Windows 10, to start it and check the status of the system proceed sat as follows:

Resource monitoring screen
Resource monitoring screen
  • press the WIN-R buttons
  • type “resmon” and give
  • Select the CPU entry
  • now in the search bar inherent in the Associated Handles type the folder or file that we are trying to delete
  • Once we find the handle that locks the resource we can right-click and choose End Process

We use Process Explorer

Another powerful tool that can help us is Process Explorer, from Microsoft’s Sysinternal suite.

You can download it and start it directly live from the sysinternal site, obviously with administrative credentials.

resmon02

Next, click Find > Find Handle or DLL, now specify the name of the file to search for or the path to the locked folder. On the results found we could interact with the right button and choose whether to end them.

We use Powershell

You can also use a powershell tool to check what’s blocking the file or folder.

resmonps03

After downloading and extracting it, just type:

Import-Module C:-Scripts-FindLockingProcess.psm1

Then type:

FindLockingProcess -FileOrFolderPath “C:-test.xlsx”

To have a complete list of available commands, type:

Get-Help FindLockingProcess –Full

Now we should be able to delete the file or folder. If you have any other suggestions, please write them down in the comments.

Alvise C.

Alvise C.

Microsoft MVP Windows Expert dal 2011 fino al 2017 e dal 2017 Microsoft MVP Windows Insider. Google Certified e Comptia Security + Certified, ha scritto per WindowsBlogItalia e Windowsteca. Appassionato ed esperto dei sistemi Microsoft Windows e della sicurezza informatica. In caso di difficoltà non esitate a commentare l'articolo; prima di fare modifiche al sistema è consigliato creare un punto di ripristino. In caso di installazione di strumenti terzi prestare attenzione alle spunte ed alle installazioni supplementari superflue. Per info: [email protected]