Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Who has file open?

Status
Not open for further replies.

nuVBer

Programmer
Jul 6, 2001
63
US
Is there any script that can tell who has a particular file open on the network?
 
yes there is! This should get you started! You will need to include a reference to the Active DS Type Library

Code:
    Dim Server As String, FileName As String, User As String        'Server, File name & User name variables
    Dim objFSOps As IADsFileServiceOperations   'File Service Operations variable
    Dim objResource As IADsResource             'Resource variable
    Dim FindPos As Long                         'Position variable

    Set objFSOps = GetObject("WinNT://" & Server & "/LanmanServer") 'Open object that contains Server resources
    
    If IsEmpty(objFSOps) = False Then       'Check to see if Server resources exist
        For Each objResource In objFSOps.Resources      'Loop through the resources on the server
            If (Not objResource.User = "") And (Not Right(objResource.User, 1) = "$") Then  'Check for user be empty
                
                'Check value of Option buttons
                If optFileName.Value = True Then
                    FindPos = InStr(1, objResource.Path, FileName, 1)   'Retrieve position of file name from the path
                Else
                    FindPos = InStr(1, objResource.User, User, 1)   'Retrieve position of user name from the user
                End If
                
                If FindPos <> 0 Then    'Check to see if file position is not 0
                    'Enter file user and file path to the Search Results text box
                    frmSearchResults.txtSearchResults.Text = frmSearchResults.txtSearchResults.Text & objResource.User & &quot; --- &quot; & objResource.Path
                    
                    'Add new line to bottom of the Search Results text box
                    frmSearchResults.txtSearchResults.Text = frmSearchResults.txtSearchResults.Text & vbNewLine
                    'Refresh the Search Results form
                    frmSearchResults.Refresh
                End If
            End If
        Next
    End If
 
This doesn't quite get me there. It gets close, but it doesn't show who has a particular file open. It only tells you which folder a person is in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top