"Offering free computer help, hints, and tips to the Internet populace." Now with over 3,820 tips!

Windows XP and DOS

See Which Process Has Opened a File or Other Object

SUMMARY: Display the list of files opened by running processes in Windows XP.


 

There is often a need to determine which process has opened a particular file in Windows XP. One such example is when you are unable to delete, rename, or edit a file because Windows claims the file is opened by another process. This dialog often does not say which process has access to a file, only that the file is locked.

To help determine which process currently has exclusive rights to a particular file, you can download a command appropriately named handle from the Sysinternals site, part of Microsoft Technet.

Simply download the zip file Handle.zip, unzip the contained executable to your main Windows directory, and you can display all open file handles with the following command:

handle

The results (which you should either pipe to more or to an external file because there will be several pages) will show each open process followed by the handles opened by said process. If you want to match up process IDs (PIDs) to processes shown in the Windows Task Manager:

1. From the Windows Task Manager, select "View" - "Select Columns".

2. When the "Select Columns" dialog box appears, check "PID (Process Identifier)".

3. Click "OK" to close the "Select Columns" dialog box.

If you want to display other open handle types including Registry keys and threads, add the -a option:

handle -a

Use the -p option to limit shown handles to those of a process name matching what you desire. For example, to show all open file handles of all Notepad processes, issue this command:

handle -p notepad

If you want to know which process has a particular file or other object opened, just add part of the filename after the command. For example, to find any processes that are currently accessing files containing the name or path of Rhapsody, issue this command:

handle rhapsody

Other options:

-c

Close the handle specified by a following hexadecimal number. Note that this can cause software or your operating system to crash, with possible loss of file information.

-y

Do not prompt when closing a handle mentioned when using the -c option.

-l

When used with the -a option, shows pagefile-backed section handles.

-s

Displays a count of the types of handles opened, including ports, directories, events, files, threads, timers, and processes.

-u

When searching for which process has a particular open file or other object, this will add the username in which the process is running.

* Download Sysinternals Handle



Print This Tip

Get E-Mail When New Tips are Online

Return to the Windows XP and DOS page.

 


New in MalekTips:

RSS Feeds- Subscribe!

You want the latest tech tips and tricks in your e-mail Inbox - FREE? Type your e-mail address below and click 'Get Tips!'.
 


( sample / details )
( opt-out instructions )