Solved

utilise windows built in search functionality with wsh?

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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 need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

617 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