Replicating TASKLIST.EXE and OH.EXE functionality in Perl
hackdaddy
created: 2006-01-04 21:48:33
I need to be able to move a directory that is being used by another process, and, hence, locked.

I can write a Perl wrapper around TASKLIST.EXE and OH.EXE to find the process that has an open handle on the directory, and then kill the process. However, I am wondering if it is possible to find the open handles of each process using only Perl. Thanks.

C:\scratch2>oh -p 152
00000098 cmd.exe        KeyedEvent     0004 \KernelObjects\CritSecOutOfMemoryEvent
00000098 cmd.exe        Directory      0008 \KnownDlls
00000098 cmd.exe        File           000c \scratch2\freddy.old
00000098 cmd.exe        Directory      0014 \Windows
00000098 cmd.exe        WindowStation  0024 \Windows\WindowStations\WinSta0
00000098 cmd.exe        Directory      0028 \BaseNamedObjects
00000098 cmd.exe        WindowStation  002c \Windows\WindowStations\WinSta0
00000098 cmd.exe        Desktop        0030 \Default
00000098 cmd.exe        Key            0034 \REGISTRY\MACHINE
00000098 cmd.exe        Key            0044 \REGISTRY\MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32
00000098 cmd.exe        Key            0054 \REGISTRY\MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32
00000098 cmd.exe        Semaphore      0058 \BaseNamedObjects\shell.{A48F1A32-A340-11D1-BC6B-00A0C90312E1}
00000098 cmd.exe        Key            005c \REGISTRY\USER\S-1-5-21-329068152-838170752-1801674531-8171
00000098 cmd.exe        File           0060 \WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9
00000098 cmd.exe        Event          0064 \BaseNamedObjects\userenv:  User Profile setup event
00000098 cmd.exe        Key            0068 \REGISTRY\MACHINE\SYSTEM\ControlSet001\Control\Nls\Locale
00000098 cmd.exe        Key            006c \REGISTRY\MACHINE\SYSTEM\ControlSet001\Control\Nls\Locale\Alternate Sorts
00000098 cmd.exe        Key            0070 \REGISTRY\MACHINE\SYSTEM\ControlSet001\Control\Nls\Language Groups


Re: Replicating TASKLIST.EXE and OH.EXE functionality in Perl
created: 2006-01-05 00:23:31
However, I am wondering if it is possible to find the open handles of each process using only Perl.
Its possible. You simply grab a few modules, and then reimplement what tasklist.exe oh.exe do. At the very least you should use Win32::Process::Info and Win32::API (while reading msdn).

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

perlmonks.org content © perlmonks.org and hackdaddy, PodMaster

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03