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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List all users that have a file open

Status
Not open for further replies.

ottman2

Programmer
Jun 26, 2001
20
0
0
US
Is there a way to determine all users or machines that have a particular file open?
 
on win2000, xp, 2003.

Right click my computer > Manage > Shared Folders > Open Files
 
This script looks for 3 different files and reports who has them open to an excel spreadsheet. You have to be a system admin to run it.




On Error Resume Next
Dim fso
Dim FindPos
Dim RowNumber, ColumnNumber, XL

ColumnNumber=1
RowNumber=1

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

Set fso = GetObject("WinNT://mcmnetapp/LanmanServer")

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, "Axys32.exe" ,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
FindPos = Instr(1, resource.path, "Rep32.exe" ,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
FindPos = Instr(1, resource.path, "Rex32.exe" ,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"

 
I'm not sure about the path syntax.
Set fso = GetObject("WinNT://mcmnetapp/LanmanServer")
If I want to hit a Windows Server2003 named "testserver" with a shared folder name "maindata". How would I type the syntax?
 
Set fso = GetObject("WinNT://testserver/LanmanServer")

The shared folder has no bearing. Put the name of the application you want to see instead of Rep32.exe or one of the other .exe I have listed.

FindPos = Instr(1, resource.path, "Rep32.exe" ,1)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top