On a regular basis, top Microsoft executives answer readers' toughest technical questions about Windows-based systems. This installment of "Ask Microsoft" was answered by Mike Mercer, Microsoft Remote IT Services, GTS.
Question: I am often confronted with a problem in Windows 2000 Server where I need to determine which process has locked a particular file. If I can figure out how to do that, I can kill it rather than have to restart the server. Is there an easy way to do that?
Answer: Most often this issue occurs when you want to delete a file and you receive the error message stating "The process cannot access the file because it is being used by another process."
In order to identify the process that has 'locked' the file from use by other processes you can
run one of two command line tools. One option from the Windows 2000 Resource Kit is "OH.exe" (Open
Handles). Another option is a third party tool developed by Sysinternals called
"handle.exe". Both tools will identify the process that has a lock on the file. You can then
use either Task Manager or the command line execution of "kill.exe
The one disadvantage to using OH.exe is the first time you attempt to use OH.exe it will prompt for a reboot. The reason for this is that OH.exe needs to enable a kernel option that makes tracking the handles possible while
Requires Free Membership to View
A side note would be that if you find that the process that has locked the file is the 'system' process, use 'net files' tool from the command line to identify the user that has the file open over a network share.
OH.exe is a free download from Microsoft at: http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/oh-o.asp.
Handle.exe is a free download from Sysinternals at: www.sysinternals.com
-- Mike Mercer
Enterprise Server Strategies for the CIO
Join the conversationComment
Share
Comments
Results
Contribute to the conversation