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\CritSecOutO +fMemoryEvent 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\Wi +nSta0 00000098 cmd.exe Directory 0028 \BaseNamedObjects 00000098 cmd.exe WindowStation 002c \Windows\WindowStations\Wi +nSta0 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.{A +48F1A32-A340-11D1-BC6B-00A0C90312E1} 00000098 cmd.exe Key 005c \REGISTRY\USER\S-1-5-21-32 +9068152-838170752-1801674531-8171 00000098 cmd.exe File 0060 \WINDOWS\WinSxS\x86_Micros +oft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1 +ff9 00000098 cmd.exe Event 0064 \BaseNamedObjects\userenv: + User Profile setup event 00000098 cmd.exe Key 0068 \REGISTRY\MACHINE\SYSTEM\C +ontrolSet001\Control\Nls\Locale 00000098 cmd.exe Key 006c \REGISTRY\MACHINE\SYSTEM\C +ontrolSet001\Control\Nls\Locale\Alternate Sorts 00000098 cmd.exe Key 0070 \REGISTRY\MACHINE\SYSTEM\C +ontrolSet001\Control\Nls\Language Groups



In reply to Replicating TASKLIST.EXE and OH.EXE functionality in Perl by hackdaddy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.