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

Retrieving Folder attributes: "Owner"

Status
Not open for further replies.

DRH192

Programmer
Joined
Apr 25, 2005
Messages
96
Location
GB
Is there any way to retrieve the owner of a folder. I can easily get file details but the information you can retrieve for folders seems limited.

Any help much appreciated

Cheers
 
DRH192,
This should get you moving in the right direction:


It's VBS so it should be pretty easy to port over to VBA

Hope this helps

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Yes it is working find here for VBA

Public Function fctGetOwner(strFile As String) As String
Dim objWMIService As Object

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Set colitems = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile & "'}" _
& " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner")

For Each objitem In colitems
' MsgBox objItem.ReferencedDomainName
' MsgBox objItem.AccountName
fctGetOwner = objitem.AccountName
Next


End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top