Recipe 6.11. Viewing the Handles a Process Has OpenProblemYou want to view all the handles a process has open. This is handy if you want to find out all of the files and registry keys a particular process is using. SolutionUsing a graphical user interface
Using a command-line interfaceTo view all of the handles a process has open, use the following command: > handle -a -p <ProcessName> You can also search for a specific handle using the following command: > handle <HandleName> For example, if you want to find all processes that have the c:\test directory open, you would replace <HandleName> with c:\test. Using VBScriptThere are no scripting interfaces to get this information. To get it programmatically, you must use the Win32 API or .NET Framework, or shell out to the handle utility. DiscussionHave you ever wanted to see all of the resources a particular process is using? Perhaps you have a new application or service and you want to see what files it touches, what registry keys it has open, what Windows stations it uses, etc. The lovely Process Explorer (and handle.exe command-line equivalent) can give you this and much more. The cool thing about Process Explorer is that it even lets you close a particular handle if you want to; from the bottom window simply right-click on the handle and select Close Handle. This is helpful if you are trying to delete a file or Registry key, but a process has a lock on it. |