Solved

utilise windows built in search functionality with wsh?

Posted on 2004-04-15
2
143 Views
Last Modified: 2010-05-02
I would like to search inside a bunch of files on a cdrom with user specific search words from a multimedia app. either  using simply a vbs file or the scripting host activex control.

Can I open the windows search assistant [search:files and folders] from a .vbs file with the search options prefilled e.g.

search files/folders named: e.g *.doc *.txt *.xls
containing txt: user entered search terms
Look in: e.g. H:

start the search and display the results in either a file or just in the results window.
0
Comment
Question by:antonumia
2 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 250 total points
ID: 10848665
You can open the "Find Files" window but I don't believe you'll be able to programmatically enter search criteria from VBS (could be wrong though).

Couldn't you just use the FSO though? Here's an example you'll have to convert. It should be mostly compatible.

Private Sub Form_Load()
    'Searches all folders within 'c:\windows\' and prints results to debug
    Call FindExt("c:\windows\", ".txt")
End Sub
Private Sub FindExt(ByVal sPath As String, ByVal sExts As String)
    Dim oFSO As Object, oFile As Object, oFolder As Object
    Dim oFiles As Object, oFolders As Object
    Dim sExt() As String, iLoop As Integer
    sExt = Split(sExts, ",")
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oFolder = oFSO.GetFolder(sPath)
    For Each oFile In oFolder.Files
        For iLoop = LBound(sExt) To UBound(sExt)
            If LCase(Right(oFile, Len(sExt(iLoop)))) = LCase(sExt(iLoop)) Then
                Debug.Print oFile
            End If
        Next iLoop
    Next oFile
    Set oFolders = oFolder.SubFolders
    For Each oFolder In oFolders
        Call FindExt(oFolder, sExts)
    Next oFolder
End Sub
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now