avery Posted December 3, 2009 Share Posted December 3, 2009 I am trying to determine who owns a file or folder. Similar to using the dir command I guess: dir /Q EX: C:\abox>dir /Q c:\temp Volume in drive C is SystemDrive Volume Serial Number is 889D-E83E Directory of c:\temp 10/16/2009 10:18 AM <DIR> WPBLEX7586\MS2admin . 10/16/2009 10:18 AM <DIR> BUILTIN\Administrators .. 10/16/2009 10:18 AM <DIR> ACCT03\rharri14 MS2 0 File(s) 0 bytes 3 Dir(s) 103,685,095,424 bytes free C:\abox> I am looking to just capture the owner part but is there a built in method to get the owner before I start using external commands? Please and Thanks! Avery Howell ------- ------- ------- I made several search attempts with no luck, ex: http://www.autoitscript.com/forum/index.php?app=core&module=search&do=quick_search&search_filter_app[forums]=1 www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org Link to comment Share on other sites More sharing options...
exodius Posted December 3, 2009 Share Posted December 3, 2009 (edited) How about this? (Taken from here)**Note - This seems to work for local inquiries, I imagine a different variation of it will be necessary for network paths.Dim $objSD $varFolderName = "C:\Data" $oWMIService = ObjGet("winmgmts:") $oFolderSecuritySettings = $oWMIService.Get("Win32_LogicalFileSecuritySetting='" & $varFolderName & "'") $intRetVal = $oFolderSecuritySettings.GetSecurityDescriptor($objSD) If $intRetVal = 0 Then MsgBox (0, "", "Owner: " & $objSD.Owner.Domain & "\" & $objSD.Owner.Name) Else MsgBox (0, "", "Couldn't retrieve security descriptor.") EndIf Edited December 3, 2009 by exodius Link to comment Share on other sites More sharing options...
avery Posted December 4, 2009 Author Share Posted December 4, 2009 How about this? (Taken from here) **Note - This seems to work for local inquiries, I imagine a different variation of it will be necessary for network paths. Dim $objSD $varFolderName = "C:\Data" $oWMIService = ObjGet("winmgmts:") $oFolderSecuritySettings = $oWMIService.Get("Win32_LogicalFileSecuritySetting='" & $varFolderName & "'") $intRetVal = $oFolderSecuritySettings.GetSecurityDescriptor($objSD) If $intRetVal = 0 Then MsgBox (0, "", "Owner: " & $objSD.Owner.Domain & "\" & $objSD.Owner.Name) Else MsgBox (0, "", "Couldn't retrieve security descriptor.") EndIf Thanks for the code. I am going to try it out and it's going to run on about 17,500,000 files/folders. I wonder how long it will take. If anyone can think of a way to speed it up please say so. www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org Link to comment Share on other sites More sharing options...
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