LurchMan Posted November 8, 2011 Posted November 8, 2011 (edited) Hey everyone -I was doing a search across the forum and couldn't find an easy solution to getting the owner of a file without using Dir /q and without using external apps. The credit for this little script goes to Tech Net: (http://gallery.technet.microsoft.com/scr...ter/7808f37b-30ca-4c76-a003-66). I just modified it to make it work with AutoIt. Also, UNC pathing doesn't work with this, you have to have a drive letter.Func _GetOwner ($sFilePath) Local $objSD $objWMIService = ObjGet("winmgmts:") $objFileSecuritySettings = _ $objWMIService.Get("Win32_LogicalFileSecuritySetting='" & $sFilePath & "'") $intRetVal = $objFileSecuritySettings.GetSecurityDescriptor($objSD) If $intRetVal = 0 Then Return $objSD.Owner.Domain & "" & $objSD.Owner.Name Else Return -1 EndIf EndFunc Edited November 8, 2011 by LurchMan Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now