Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

utilise windows built in search functionality with wsh?

Posted on 2004-04-15
2
150 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

840 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