Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

utilise windows built in search functionality with wsh?

Posted on 2004-04-15
2
Medium Priority
?
158 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
[X]
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
2 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

719 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