SZachmann
asked on
List open files in a shared folder
Experts
I want to list all of the open files in a shared folder, if you go to computer management > Shard Folders > Open Files, you can see the list I am talking about.
I am aware that I could open a command prompt and run the command Net Files but I was wondering if there was a way to query this list without going through the command prompt. I have been trying to use WMI queries but I cannot figure out how to have it list the path of the open file.
Any help would be appreciated.
Thanks!
I want to list all of the open files in a shared folder, if you go to computer management > Shard Folders > Open Files, you can see the list I am talking about.
I am aware that I could open a command prompt and run the command Net Files but I was wondering if there was a way to query this list without going through the command prompt. I have been trying to use WMI queries but I cannot figure out how to have it list the path of the open file.
Any help would be appreciated.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I will be honest, i'm not sure.
You might find this snippet of code useful, it is one method i use that allows wildcard searching (for part of filename or foldername) and puts the result in Excel. Just paste it into a vbs and change 'yourservername' to match your fileserver, double click it and type your filename.
Hope this helps.
You might find this snippet of code useful, it is one method i use that allows wildcard searching (for part of filename or foldername) and puts the result in Excel. Just paste it into a vbs and change 'yourservername' to match your fileserver, double click it and type your filename.
Hope this helps.
On Error Resume Next
Dim fso
Dim FindPos, Input
Dim RowNumber, ColumnNumber, XL
ColumnNumber=1
RowNumber=1
Input = InputBox("Enter any part of Filename","Case Insensitive")
Set XL = CreateObject("Excel.Application")
XL.workbooks.add
XL.Visible = TRUE
XL.Cells(RowNumber, ColumnNumber).Value = "User"
XL.Cells(RowNumber, ColumnNumber+1).Value = "Path"
RowNumber=RowNumber+1
' Bind to a file service operations object on servername" in the local domain.
Set fso = GetObject("WinNT://yourserver/LanmanServer")
' Enumerate resources
If (IsEmpty(fso) = False) Then
For Each resource In fso.resources
If (Not resource.User = "") And (Not Right(resource.User,1) = "$") Then
FindPos = Instr(1, resource.path, Input ,1)
If (FindPos <> 0) Then
XL.Cells(RowNumber, ColumnNumber).Value = resource.user
XL.Cells(RowNumber, ColumnNumber+1).Value = resource.Path
RowNumber=RowNumber+1
End if
End If
Next
End If
XL.Cells.EntireColumn.Autofit
Set XL=nothing
MsgBox "Done"
ASKER