Display file owner (VBScript)
This code can be found in
Chapter 10 of Windows Server 2003 Security Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the VBScript code from this site.
' This code prints the owner of a file.
' ------ SCRIPT CONFIGURATION ------
strFile = "<FilePath>" ' e.g. d:\scripts\foo.vbs
strComputer = "<ServerName>" ' e.g. rallen-svr1 or . for local server
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colItems = objWMI.ExecQuery _
("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile & "'}" _
& " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner")
for each objItem in colItems
Wscript.Echo "Owner: " & objItem.ReferencedDomainName & "\" & _
objItem.AccountName
next
|
This code has been viewed 3583 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|