# VBscript file search

Does anyone know if there is a way through VBscript to search an entire server for any occurance of a ".mdb" file and then write the finding information to an output file showing the name of the file, location, owner, date last accessed, date created, and date modified?

I really appreciate your help or suggestions.
Thanks
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Database Architect / Systems AnalystCommented:
How 'big' is your 'entire server' ?

If I did that here, even with the faster Cray supercomputer, it would probably take a looooong time.

mx
0
Commented:
see the codes from this link

http://allenbrowne.com/ser-59.html

0
MIS LiasonCommented:
...MX,
...isn't the "Owner" of the DB is something you would have to open the db file to determine....
(making this a bit more complex)
0
IT / Software Engineering ConsultantCommented:
Give this a try, save as a VBS script and adjust the starting folder.  Try it on a small subfolder first to get an idea if it's getting the info you want before you run it on a larger drive or share.  It will certainly take a while to search a large drive, no matter what tool you use.

sFolder = "c:\ee"

Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")

DoSearch oFSO.GetFolder(sFolder)

Sub DoSearch(oFolder)
For Each oFile in oFolder.Files
If LCase(Right(oFile.Name, 4)) = ".mdb" Then
WScript.Echo "Name = " & oFile.Name
WScript.Echo "Path = " & oFile.Path
WScript.Echo "Owner = " & GetOwner(oFile.Path)
WScript.Echo "DateLastAccessed = " & oFile.DateLastAccessed
WScript.Echo "DateCreated = " & oFile.DateCreated
WScript.Echo "DateLastModified = " & oFile.DateLastModified
WScript.Echo "-------------------------------------"
End If
Next
For Each oSubFolder In oFolder.Subfolders
DoSearch(oSubFolder)
Next
End Sub

Function GetOwner(sFile)
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Set cItems = oWMI.ExecQuery("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & sFile & "'} WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner")

For Each oItem in cItems
GetOwner = oItem.ReferencedDomainName & "/" & oItem.AccountName
Next
End Function

~bp
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Beautiful!! That's exactly what I was looking for.
Thanks!!!
0
IT / Software Engineering ConsultantCommented:
Welcome, glad that helped, thanks for the feedback.

~bp
0
Author Commented:
Thanks!!
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.