Jump to content

Recommended Posts

Posted

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!)

Posted

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

  • Thanks 1
Posted (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 by Sheridan
Posted
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.
  • Thanks 1
Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



  • 47 When would you like EduGeek EDIT 2025 to be held?

    1. 1. Select a time period you can attend


      • I can make it in June\July
      • I can make it in August\Sept
      • Other time period. Comment below
      • Either time

×
×
  • Create New...