bfreescott
Board Regular
- Joined
- Aug 6, 2015
- Messages
- 115
Hi guys
So, like many, my goal is to try and determine the name of a network user who has an excel file on a mapped network drive currently open.
I've chased many rabbits on this and have come to what I hope is a solution using the WMI library, but I'm getting an invalid path error with my function.
Has anyone had success with WMI?
So, like many, my goal is to try and determine the name of a network user who has an excel file on a mapped network drive currently open.
I've chased many rabbits on this and have come to what I hope is a solution using the WMI library, but I'm getting an invalid path error with my function.
Has anyone had success with WMI?
Code:
Function GetFileOwner(strFileName)
'
Set objWMIService = GetObject("winmgmts:")
Set objFileSecuritySettings = objWMIService.Get("Win32_LogicalFileSecuritySetting='" & strFileName & "'")
intRetVal = objFileSecuritySettings.GetSecurityDescriptor(objSD)
If intRetVal = 0 Then
GetFileOwner = objSD.Owner.Name
Else
GetFileOwner = "Unknown"
End If
'
End Function