#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
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 2630 anonymous users online.
|
|
|