Determining which process has a file open with Process Explorer

Have a dream? Start learning your way toward it with courses from $12.99. Shop now for extra savings1px

When I attempted to copy an Outlook .ost file to an external USB flash drive, I saw the message below:

An unexpected error is keeping you from copying the file. If you continue to receive this error, you can use the error code to search for help with this problem.

Error 0x80070021: The process cannot access the file because another process has locked a portion of the file.

I didn't have Outlook open and didn't know what other process was using the file. One way to find out which process has a lock on a file is to use the Process Explorer utility provided by Microsoft. The program is free and you don't need administrator rights on a system to use it. To determine a process that is using the file, you can hit the Ctrl and F keys simultaneously, which will bring up a search box where you can type the name of the relevant file. When you click on the Search button, you should be able to see the name of the process that has a lock on the file as well as the process ID (PID) for that process. E.g., in this case I could see that lync.exe was using the file.

Process Explorer Search

I didn't have administrator rights on the system and couldn't run the Windows Task Manager to kill the process using it. But I could kill it from a command prompt using the taskkill command, though I had to use the /f option to force the termination of the process. I wasn't able to copy the file immediately afterwards, but I was able to copy it shortly afterwards at which time when I searched on the "handle or DLL substring" in the Process Explorer Search box again, no results were returned.

Anonymous Online: The Ultimate Guide to Online Privacy
Anonymous Online
The Ultimate Guide to Online Privacy
1x1 px

C:\Users\jmcamer1>tasklist /fi "imagename eq lync.exe"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
lync.exe                     14108 Console                    2    162,592 K

C:\Users\jmcamer1>taskkill /fi "imagename eq lync.exe"
SUCCESS: Sent termination signal to the process with PID 14108.

C:\Users\jmcamer1>tasklist /fi "imagename eq lync.exe"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
lync.exe                     14108 Console                    2    162,912 K

C:\Users\jmcamer1>taskkill /f /fi "imagename eq lync.exe"
SUCCESS: The process with PID 14108 has been terminated.

C:\Users\jmcamer1>tasklist /fi "imagename eq lync.exe"
INFO: No tasks are running which match the specified criteria.

C:\Users\jmcamer1>

Related articles:

  1. Error stating Outlook OST file is in use and cannot be accessed