Pegasus [MVP] schrieb:
> "Oli M" <OliM@xxxxxx> wrote in message
> news:1ABFE01F-C72A-4B5B-9876-D9A801A7AEA1@xxxxxx [...]
> Here is the recursive part of the solution. You must invoke it with
> cscript.exe.
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oFolder = oFSO.GetFolder("F:\")
> GetFiles(oFolder)
>
> Sub GetFiles(oFldr)
> For Each oFile In oFldr.Files
> WScript.Echo oFile.path
> Next
> For Each oSubFolder In oFldr.Subfolders
> GetFiles(oSubFolder)
> Next
> End Sub
>
> You can use it as the basis for the remaining tasks, i.e.
> - Pick the files that match your wildcard spec;
> - Use the Run method to invoke the executable you found.
>
> You will find everything you need in the downloadable help file
> script56.chm. Look for the "left" and "right" functions and for the "run" or
> "exec" methods. Ok, I'll add the the 'find the .exe' sub part of the problem:
Const csCDRoot = "<YourCDRoot>"
Dim oFSO : Set oFSO = CreateObject( "Scripting.FileSystemObject" )
Dim oWSH : Set oWSH = CreateObject( "WScript.Shell" )
Dim oRE : Set oRE = New RegExp
oRE.IgnoreCase = True
oRE.Pattern = "^sdat\d+\.exe$" ' <== sdat5555.exe and then the next sdat5556.exe
ExecCDFiles oFSO.GetFolder( csCDRoot ), oFSO, oRE, oWSH
Sub ExecCDFiles( oFldr, oFSO, oRE, oWSH )
Dim oItem
For Each oItem In oFldr.Files
WScript.Echo "seen ", oItem.Path
If oRE.Test( oItem.Name ) Then
WScript.Echo "match", oItem.Path
End If
Next
For Each oItem In oFldr.Subfolders
ExecCDFiles oItem, oFSO, oRE, oWSH
Next
End Sub
[I admit that I did it mainly to remove those nasty () from Pegasus' code]