Re: Check for file open handles
From: C O Jones (umdegraf_at_cc.umanitoba.ca)
Date: 10/27/04
- Next message: Michael Harris \(MVP\): "Re: VB script skelleton"
- Previous message: Hal Rosser: "Re: Help With Checkboxes"
- In reply to: Yuri Weinstein \(HotMail\): "Check for file open handles"
- Next in thread: Yuri Weinstein \(HotMail\): "Re: Check for file open handles"
- Reply: Yuri Weinstein \(HotMail\): "Re: Check for file open handles"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 27 Oct 2004 18:41:48 -0500
Try this
'
'
' Name:
'
'
'
' isFileOpen.vbs
'
'
'
' Description:
'
'
'
' This function checks to see if the given file is open on the given
server. You may '
' specify any portion of the fully qualified file name, however, you will
want to make '
' sure that whatever you specify is enough to uniquely identify the file
since searching '
' stops on the first matching file. If the file is open, user and path
return the name '
' of the user who has it open, and the fully qualified file name of the
matching file. '
'
'
' Notes:
'
'
'
' With a simple mod you could have the function pass back a dictionary of
ALL files that '
' are open and that match the given file. You could then check to see if
a given file is '
' in that dictionary.
'
'
'
' Usage:
'
'
'
' result = isFileOpen (server,file,user,path)
'
'
'
' server: the name of a server (eg EMSWEB)
'
' file: part or all of a file name (eg \emsnt1\scd\scd-dir\Top\Paul
MISO\WOLF\07-02 '
' user: the login id of the user who has the file open
'
' path: the fully qualified name of the open file.
'
'
'
' Audit:
'
'
'
' 2004-07-02 jdeg original code
'
'
'
Function isFileOpen ( server , file , user , path )
dim fso
dim resource
isFileOpen = True
Set fso = GetObject("WinNT://" & server & "/LanmanServer")
on error resume next
If (IsEmpty(fso) = False) Then
For Each resource In fso.resources
user = resource.User
path = resource.Path
if err.Number = 0 then
If (Not user = "") And (Not Right(user,1) = "$") Then
if Instr(1,path,file,1) > 0 then exit Function
End If
else
err.Clear
end if
Next
End If
on error goto 0
isFileOpen = False
End Function
- Next message: Michael Harris \(MVP\): "Re: VB script skelleton"
- Previous message: Hal Rosser: "Re: Help With Checkboxes"
- In reply to: Yuri Weinstein \(HotMail\): "Check for file open handles"
- Next in thread: Yuri Weinstein \(HotMail\): "Re: Check for file open handles"
- Reply: Yuri Weinstein \(HotMail\): "Re: Check for file open handles"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|