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 strongm 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
Apr 25, 2005
96
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
 
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