Demonstration script that reads the security descriptor for a folder (specified by the strFolderName variable) and retrieves the domain and name of the owner of the folder from the descriptor.

Visual Basic
Edit|Remove
strFolderName = "C:\scripts\sec_center"
Set objWMIService = GetObject("winmgmts:")
Set objFolderSecuritySettings = _
objWMIService.Get("Win32_LogicalFileSecuritySetting='" & strFolderName & "'")
intRetVal = objFolderSecuritySettings.GetSecurityDescriptor(objSD)

If intRetVal = 0 Then
   WScript.Echo "Owner: " & objSD.Owner.Domain & "\" & objSD.Owner.Name
Else
   WScript.Echo "Couldn't retrieve security descriptor."
End If