Sheridan Posted May 12, 2011 Report Posted May 12, 2011 Has anyone found a way (scripting/VB etc) to produce a list of files for a particular owner (i.e the NTFS owner) I'd like to do some maintenance and this would be really handy but I havne't found a way in Vb6 (yet!)
cromertech Posted May 12, 2011 Report Posted May 12, 2011 I found one on this site VBScript : Find Files By Owner Set objShell = CreateObject ("Shell.Application") Set objStartFolder = objShell.Namespace ("N:\") Set objFSO = CreateObject("Scripting.FileSystemObject") strUsername = "DOMAIN\User" oFolder = "N:\" Dim arrHeaders(13) ShowSubfolders objFSO.GetFolder(oFolder) Sub ShowSubFolders(Folder) On Error Resume Next For Each Subfolder in Folder.SubFolders Set oNsp = objShell.Namespace(Subfolder.Path) 'Dim arrHeaders(13) For i = 0 to 13 arrHeaders(i) = oNsp.GetDetailsOf (oNsp.Items, i) Next For Each strFileName in oNsp.Items If LCASE(oNsp.GetDetailsOf (strFileName, 8)) = LCASE(strUsername) Then Wscript.Echo Subfolder.Path & "\" & strFilename & "," & arrHeaders(1) & "," & Replace(oNsp.GetDetailsOf (strFileName, 1),",","") End If Next ShowSubFolders Subfolder Next End Sub As the site says you can pipe the results to a file and maybe get it ask for the username you want or parse the users from active directory 1
Sheridan Posted May 12, 2011 Author Report Posted May 12, 2011 Thats looks like just what I'm after - thanks! (I didn't even see that site in my google searches )
Sheridan Posted May 12, 2011 Author Report Posted May 12, 2011 (edited) Hmm I don't seem to be able to get this working - when I run and check whats being picked up as the owner, it always shows it as 'not available' EDIT - Seems to be when running Windows 7 - ran it on Server 2003 and now getting the results I was expecting! job done! Edited May 12, 2011 by Sheridan
ChrisMiles Posted May 12, 2011 Report Posted May 12, 2011 If you have windows 7 or server 2008 r2 you can add owner as a column to the normal explorer view and use it to sort. Easy Just rick click on the headers in detail view and click more, select owner and click ok. You can then click the owner header to sort. 1
Sheridan Posted May 13, 2011 Author Report Posted May 13, 2011 The Win7 view is useful - but I needed to extract it so I could put it into a spreadsheet and sort/find items. Got the script working on Win7 now as well - I must have made a typo or something originally.
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