Categories Articles

Key to success: Tracking down and unlocking locked files in Windows

If I were to make a list of the most frustrating things that sometimes happen when using Windows (something my colleague Mitch Tulloch has already done), locked files would definitely be an item on the list. We have all occasionally received an error message stating that “the action can’t be completed because the folder or file is open in another program.” Most of the time, fixing the error is simply a matter of closing whichever application currently has the file open. Sometimes though, things aren’t that simple, and Windows claims that a file is locked, even though it isn’t actually open.

Unfortunately, there is no silver bullet solution or magical cure-all that will make this problem go away (with the possible exception of rebooting). There are, however, a number of different things that you can do to get to the root cause of the problem. Before I tell you what these possible remedies are, I need to point out that I am using Windows 10 as the basis for this article, although it is likely that the techniques that I am about to show you will also work in other Windows versions.

What causes a file to become locked?

Windows locks certain types of files to prevent them from being modified simultaneously by two different users or two different applications. Normally, a file lock is engaged when the file is open, and Windows releases the lock when the application associated with the file is closed.

In my experience, two main things tend to cause files to remain locked even after their corresponding application is closed. One possibility is that temporary files used by the application were not properly cleared out when the application closed. Another possibility is that a portion of the application, such as an individual process, continues to run even though the application itself has been terminated.

Temporary files

Every application is different, so it can be a little bit tricky to track down the temporary files that are being used by a program. Thankfully, the issue of temporary files not being deleted properly is less common than that of processes not terminating properly.

Although an application could conceivably be designed to store its temporary files almost anywhere, there are two main locations that you should check. These include:

C:\Temp
C:\Users\<username>\AppData\Local\Temp

Go to these locations, and any other temporary file repository, and delete their contents. Typically, you will find that there were some files that you won’t be able to delete. There may be temporary files for example, that are actively being used by the operating system, and therefore cannot be deleted. It is normally safe to delete any temporary files that Windows is not currently using, but if you are concerned about causing damage then you can always create a backup of the files before removing them.

Running processes

The more common cause for files remaining locked even after they have supposedly been closed is that an individual process associated with the application that had been using the file continues to run even though the application itself has been closed. While you can correct this problem by simply rebooting the machine, reboots tend to be inconvenient. Thankfully, there are ways to track down the offending process without having to reboot your computer.

The easiest thing that you can do is to open the Windows Task Manager, and simply browse the list of processes to see if there are any processes listed that correspond to the application that was last used to open the file. If you encounter such a process, then all you have to do is select the process, and then click on the End Task button.

Of course, there may be a large number of processes running on your computer, making it tricky to find the process that you are interested in. If that is the case, then it may be easier to use Windows PowerShell. Just use the Get-Process cmdlet, followed by the application name and an asterisk. Right now, for example, I am using an application called Dragon Naturally Speaking to dictate this article. If I wanted to use PowerShell to see if Dragon had any processes open, I could use this command:

Get-Process Dragon*

As you can see in the figure below, PowerShell has returned a result. If you find a running process that should not be running, you can stop it by entering the Stop-Process cmdlet, followed by the -Name parameter, and the name of the process that you want to stop.


By far the best tool for tracking down the cause of a locked file is Process Explorer. Process Explorer is a free tool from Sysinternals. You can download Process Explorer here. You can see what Process Explorer looks like in the next screenshot.


As you look at the colorful screen capture above, you will notice that the toolbar contains an icon that looks like binoculars. Click on this icon to open the Process Explorer Search interface. Enter all or part of the name of your locked file, and then click the Search button. As you can see in the next figure, Process Explorer will show you exactly which process has the file locked.

When you click on the process within the list of results, Process Explorer will take you to the corresponding process within the overall list of processes. From there, all you have to do is to close the process.

Locked files: Other fixes

It can be a maddening experience when Windows holds a file open even though it should be closed. Thankfully, it is usually relatively easy to get a locked file unlocked. If you find that none of the techniques that I have discussed can unlock your file (and you are sure that nobody else is using the file), then try emptying the Windows Recycle Bin and rebooting the computer. That will almost always fix the problem.

Featured image: Shutterstock

Brien Posey

Brien Posey is a freelance technology author and speaker with over two decades of IT experience. Prior to going freelance, Brien was a CIO for a national chain of hospitals and healthcare facilities. He has also served as a network engineer for the United States Department of Defense at Fort Knox. In addition, Brien has worked as a network administrator for some of the largest insurance companies in America. To date, Brien has received Microsoft’s MVP award numerous times in categories including Windows Server, IIS, Exchange Server, and File Systems / Storage. You can visit Brien’s Website at: www.brienposey.com.

Share
Published by
Brien Posey

Recent Posts

Facebook creating deep fakes — and for genuinely good reasons

Deep fakes are a catastrophe waiting to happen. Facebook’s attempt to create a tool that differentiates between real and fake…

18 hours ago

Microsoft Intune gets a new streamlined user experience

Microsoft Intune is getting a bunch of new updates that will streamline the administration experience for users of the popular…

22 hours ago

SD-WAN: Is this going to be your network of the future?

As businesses evolve into a SaaS/IaaS model for accessing applications, new network technology is crucial. SD-WAN is just such a…

1 day ago

Monitoring Exchange and the rest of your network to avert disasters

What you don’t know about Exchange and your network can come back to bite you. Monitoring Exchange is one way…

2 days ago

Quick tip: Removing warning messages from Azure cmdlets

Warnings are nice, except when they are annoying and unnecessary. Here’s a tip to show you how to remove warning…

2 days ago

Is the Group Policy Central Store still relevant in the age of Windows 10?

Having a Group Policy Central Store in Active Directory made life easier for administrators. But does it still work in…

2 days ago