Display open file handles (Perl)

This code can be found in Chapter 8 of Windows XP Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the Perl code from this site.

# From the book "Windows XP Cookbook"
# ISBN: 0596007256

# This code prints the output from the handle.exe command
# ------ SCRIPT CONFIGURATION ------

use Win32::OLE;

$strFilePattern = '<FileName>';
# e.g. personal.pst
$strHandleExec = 'handle.exe';
# If handle.exe isn't in your PATH, you will
# need to specify the full path.
# ------ END CONFIGURATION ---------
$objWshShell = Win32::OLE->new('WScript.Shell');
$objExec = $objWshShell->Exec($strHandleExec . ' ' . $strFilePattern);
while (!$objExec->StdOut->AtEndOfStream) {
    print $objExec->StdOut->ReadLine(), "\n";
}

This code has been viewed 1992 times.

New from the creators of TechTasks.com: StatSheet.com