#93129 - 2003-10-25 06:01 PM
Re: Open FIles (Locked)
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Les, might give this free sysinternals utility a try, we're currently using it to debug an IE6 frezzing problem ... it dumps open file handles by process etc ... not sure if it works on a file on share though ...
SysInternals Handle Utility
We kinda use it like:
F:\>handle
handle.exe pid: 2960 TASSIE\Shawn.Tassie
48: File F:\
b8: File F:\del.me
-Shawn
|
|
Top
|
|
|
|
#93134 - 2003-10-26 02:42 AM
Re: Open FIles (Locked)
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I have some Perl code put together that shows who has the file open using NetFileEnum and then forces it closed.
Granted that the closing of the file may require administrator rights. Would you like to try an simple EXE?
|
|
Top
|
|
|
|
#93136 - 2003-10-26 07:28 AM
Re: Open FIles (Locked)
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
What about something like Hyena, where you can terminate threads to a file?
Kent
|
|
Top
|
|
|
|
#93139 - 2003-11-05 11:56 PM
Re: Open FIles (Locked)
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
Solving half the problem !
I have transformed the VB code that masken found to KiX.
This will tell the user who has locks on the file, they can then phone the offending users, and ask them to close the file.
I have not tested the script with a domain user account, so it might not work, but used with admin rights it is very quick.
(Excel must be installed, because the script uses Excel for output !!)
code:
Dim $oFSO, $Resource Dim $FileName, $ServerName Dim $Row, $oXL 'Enter filename or part of filename of locked file: ' GetS $FileName ?'Enter servername: ' GetS $ServerName ? 'Checking locks for filename: ' + $FileName + ' on server: ' $ServerName $oXL = CreateObject("Excel.Application") $RC = $oXL.workbooks.add() $oXL.Cells(1, 1).Value = "User" $oXL.Cells(1, 2).Value = "Path" $oFSO = GetObject("WinNT://" + $ServerName + "/LanmanServer") $Row = 2 If VarTypeName($oFSO) = 'Object' For Each $Resource In $oFSO.Resources If $Resource.User <> "" And Right($Resource.User,1) <> "$" If InStr($Resource.Path, $FileName) $oXL.Cells($Row, 1).Value = $Resource.User $oXL.Cells($Row, 2).Value = $Resource.Path $Row = $Row + 1 EndIf EndIf Next EndIf $oXL.Cells($Row + 1, 1).Value = 'Filename: ' + $FileName $oXL.Cells($Row + 1, 2).Value = 'Number of file locks: ' + CStr($Row - 2) $RC = $oXL.Cells.EntireColumn.Autofit $oXL.Visible = True $oXL = 0
-Erik
|
|
Top
|
|
|
|
#93140 - 2003-11-06 05:10 PM
Re: Open FIles (Locked)
|
Bonji
Starting to like KiXtart
Registered: 2001-09-28
Posts: 169
Loc: Virginia
|
I took Erik's code and incorporated Kixforms as the display mechanism, however I would like to add a function that allows the lock to be removed without having to shell out and use NET FILE. I've come across some very promising leads in ADSI, however none have panned out to actually remove the lock. I was looking at IADsFileServiceOperations and Sessions/Resources related to that, and when they didn't pan out I checked all the various IADs interfaces and still came up empty. Anyone know where to point me on this assuming it is even possible to do as I wish.
Here's my version of Erik's code, and unfortunately I don't see an easy way to allow non-admins to view the locks as when a regular user runs it on our network, it just comes up with no results.
code:
BREAK ON DIM $oFSO, $Resource
$FORM = CREATEOBJECT("KIXTART.FORM") $FORM.SIZE = 600,400 $FORM.CENTER $FORM.CAPTION = "Find File Locks" $lblSERVER = $FORM.Label("Server:") $lblSERVER.SIZE = 60,15 $lblSERVER.LOCATION = 10,12 $txtSERVER = $FORM.TextBox $txtSERVER.SIZE = 70,19 $txtSERVER.LOCATION = 80,10 $lblFILE = $FORM.Label("File Name:") $lblFILE.SIZE = 60,15 $lblFILE.LOCATION = 10,42 $txtFILE = $FORM.TextBox $txtFILE.SIZE = 210,19 $txtFILE.LOCATION = 80,40 $cmdFIND = $FORM.CommandButton("Find") $cmdFIND.SIZE = 60,19 $cmdFIND.LOCATION = 160,10 $cmdFIND.ONCLICK = "cmdFIND_CLICK()" $cmdFIND.DEFAULT = 1 $cmdCANCEL = $FORM.CommandButton("Cancel") $cmdCANCEL.SIZE = 60,19 $cmdCANCEL.LOCATION = 230,10 $cmdCANCEL.ONCLICK = "$$FORM = 'NOTHING'" $cmdCANCEL.CANCEL = 1 $lblSTATUS = $FORM.Label("Status: Waiting for input") $lblSTATUS.SIZE = 200,15 $lblSTATUS.LOCATION = 10,75 $lsvLIST = $FORM.ListView $lsvLIST.SIZE = 575,260 $lsvLIST.LOCATION = 10,105 $ = $lsvLIST.COLUMNS.ADD("User",100,0) $ = $lsvLIST.COLUMNS.ADD("File",471,0) $txtSERVER.SETFOCUS $FORM.SHOW
WHILE $FORM.VISIBLE $ = EXECUTE($FORM.DOEVENTS) LOOP
FUNCTION cmdFIND_CLICK() $ = $lsvLIST.ITEMS.CLEAR $lblSTATUS.TEXT = "Status: Checking locks for filename " + $txtFILE.TEXT + " on server " + $txtSERVER.TEXT $oFSO = GetObject("WinNT://" + $txtSERVER.TEXT + "/LanmanServer") $CNT = 0 IF VARTYPENAME($oFSO) = "Object" FOR EACH $Resource IN $oFSO.Resources IF $Resource.User <> "" AND RIGHT($Resource.User,1) <> "$" IF INSTR($Resource.Path, $txtFILE.TEXT) $CNT = $CNT + 1 $ITEM = $lsvLIST.ITEMS.ADD($Resource.User) $ITEM.SUBITEMS(0).TEXT = $Resource.User $ITEM.SUBITEMS(1).TEXT = $Resource.Path ENDIF ENDIF NEXT ENDIF $lblSTATUS.TEXT = $txtFILE.TEXT + " : Number of file locks: " + $CNT ENDFUNCTION
-Ben http://www.rgcweb.org/kix [ 06. November 2003, 17:12: Message edited by: Ben Dulaney ]
|
|
Top
|
|
|
|
#93141 - 2003-11-06 08:34 PM
Re: Open FIles (Locked)
|
Bonji
Starting to like KiXtart
Registered: 2001-09-28
Posts: 169
Loc: Virginia
|
I took a shot at using NET FILE to remove the lock on files, however it is way more coding then I anticipated. One of the problems is that NET FILE does not support remote functions, so I have to schedule a job to run on the server that I want to close the file on (through AT), and then I get the file off the server (the server is our main file server so it can output the display to itself which works around any network issues with the scheduler). However, the main impediment to this is that the NET FILE command only gives 40 characters worth of data for the files so it makes matching the line from the file with the one in the listview a real pain For now I'll leave it without the functionality that would really make it useful.
-Ben http://www.rgcweb.org/kix [ 06. November 2003, 21:26: Message edited by: Ben Dulaney ]
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 2630 anonymous users online.
|
|
|