×


Unlock a file locked by any process or system - Do it now

Sometimes when we try to delete, rename or move a file in Windows, we may see a message 'unlock a file locked by any process or system'.

Usually, the program name that keeps the file open, is shown right in the File Explorer message window. To unlock the file, it is enough just to close the program.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix Windows related errors.

In this context, we shall look into how to unlock a file that shows busy/locked/used by another process.


How to unlock a file locked by any process or system ?

Here are the different methods our Support Experts provide to our customers to unlock a file locked by any process or system.


Method 1: Unlock a File using Process Explorer

ProcessExplorer is a free tool from the Sysinternals kit. We can download it from the Microsoft website.

Here is its URL:

https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer

Here is the procedure to find a process that has locked a file.

1. There is no need to install ProcessExplorer: we can simply download, extract and run procexp.exe as administrator

2. First, we select Find >> Find Handle or DLL (or press Ctrl-F)

3. Then we need to specify the file name that we want to unlock and then we click Search

4. Here, we select the file we want. The process has opened the file will be highlighted in the process tree. 

We right-click on it and select Kill Process Tree to end the process. However, we can try and close the file handle without ending the process. The filehandle we looked for is automatically highlighted in the Process Explorer bottom panel.

We right-click the handle and select Close Handle. 

Finally, we confirm closing the file.

If the bottom panel with the list of open process handles is not displayed in Process Explorer, we enable the option View >> Lower Pane View >> Handles.

So we can close the file handle without ending the parent process. 

Then we can remove or rename the file.


Method 2: Release a File Handle using the Handle Tool

The handle is another command-line tool from the Sysinternals. We can download this as well from the Microsoft website.

URL: https://docs.microsoft.com/en-us/sysinternals/downloads/handle

It allows us to find a process having locked our file and release the lock by freeing the handle.

1. First, we download and extract the Handle archive

2. Next, we open the command prompt as an administrator and run the following command:

handle64.exe > listproc.txt

3. This command will save the list of open handles to a txt file. We can display handles for a directory the file we want to change is located in:

Handle64.exe -a “C:\Program Files\App”

or for the specific process:

handle64.exe -p excel.exe

4. Then we open listproc.txt in any text editor and find the line that contains the name of the locked file. We copy the file handle ID (in hex format). Then we go up to the section where the process that owns the handle is shown and write down its ID.

For some Windows system processes, handle.exe returns the following message:

wininit.exe pid: 732 \<unable to open process>

It means that we cannot get any information about these system processes (even as administrators). To get file handles open by such processes, we run the cmd.exe as System and try to get the list of handles again.

5. Then we get back to the command prompt and reset the file handle by its HandleID and ProcessID.

Here is the command format:

handl64e.exe -c HandleID -p ProcessID

For example:

handl64e.exe -c 18C -p 18800

6. The tool will prompt to confirm the closing of the file for the process. We confirm it by pressing y >> enter.

If the system reacts to the closing of the file correctly, we will unlock the file without ending the process or restarting the server/computer.


[Need urgent assistance in unlocking a locked file? – We are here to help you. ]


Conclusion

This article covers how to unlock a file locked by any process or system. 

If everything goes correctly, you will fix this Windows problem without killing the process and – more importantly – without having to reboot the system.


To unlock a locked file in Windows 10?

1. Type the name of the locked file in the field, and click the Search button. 

2. Select the file from the search result. 

3. Behind the search window, in "Process Explorer," right-click the locked file, and select Close Handle to unlock it.


To Open a Locked File When Another Program Is Using It:

1. Close The Program That Is Using The Locked File.

2. Kill The Program Process Using Task Manager.

3. Turn Off The Preview Pane In File Explorer.

4. Toggle The Folder Process In File Explorer.

5. Launch & Close The Locked File.

6. Restart Your Windows Computer.

7. Use Command Prompt To Delete The File.