How To Natively Find Out Which Process has Locked Your File in Windows

It’s frustrating when you are trying to delete a file but only get a warning message telling you that the file is in use and cannot be deleted, isn’t it? Turns out, Microsoft already has a command line built-in Windows that lets you quickly check to find out which process is holding up your file. It’s called OpenFiles and it’s been around since Windows Vista.

File in Use window

Turn on local file tracking

기본적으로, OpenFiles only tracks the files opened by remote users through local shared folders. If you don’t have any local shared points, you see nothing.

OpenFiles - no local shares

You will need to enable the system global flag “maintain objects list” to see local opened files. Open an elevated Command Prompted window (Run as Administrator) and run this command.

OpenFiles /local on

OpenFiles - enable local tracking

Then restart your computer and you are all set.

How to use OpenFiles

Once rebooted, open an elevated Command Prompt window again and run the command. You will get the full list of files opened locally on your system. Since the list is going to be pretty long, you may want to export the outputs to a file.

OpenFiles > %userprofile%desktopfilelist.log

Or save them to the clipboard so it can be pasted later on to the notepad.

OpenFiles | Clip

You can even save the output in List or CSV formats if need.

OpenFiles /Query /FO CSV

What’s more useful is that you can combine the FileStr command to find exactly which process is locking up your file, such as below:

OpenFiles | FindStr /i document

OpenFiles - piped out to FindStr

Now you can terminate the process either through Task Manager or properly close out the application.

리소스 모니터

양자 택일로, if you prefer a GUI based tool to help you to do the same, give Resource Monitor a try.

열다 리소스 모니터 from Task Manager’s 공연 탭, switch over to CPU tab and type the file name in the search box on Associated Handles 탭. I typed in “documents” in the search box, and here is what I got.

Resource Monitor - CPU - associated handler

3rd party tools options

하나, if you are the fan of NirSoft or Sysinternals and like the tools made by them, you can definitely give both OpenFilesViewProcess Explorer a try.


회신을 남겨주

이 사이트는 스팸을 줄이기 위해 Akismet 플러그를 사용. 귀하의 코멘트 데이터가 처리되는 방법 알아보기.

우리는 당신에게 최고의 온라인 경험을 제공하기 위해 쿠키를 사용합니다. 동의함으로써 당신은 우리의 쿠키 정책에 따라 쿠키 사용을 허용.