I am trying to make a script that will run all the exe files in a specified directory. The script I have so far seems to run the bat files randomly. For testing I set up a folder with a.bat, b.bat and c.bat where a.bat runs notepad, b.bat runs calc, and c.bat runs appwiz.cpl. What happens seems totally randomly to me, sometimes calc runs, sometimes appwiz, sometimes notepad. I don't think I have seen all of them start like they are supposed to. What am I doing wrong? Here is my script:
Dim fso, startFolder
Dim WshShell, oExec
Dim folder, file, fileCollection
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
startFolder = "C:\test"
Set folder = fso.GetFolder(startFolder)
Set fileCollection = folder.Files
For Each file In fileCollection
If UCase(Right(file.Name, 4)) = ".BAT" Then
Set oExec = WshShell.Exec(file.name)
I will probably make this into an exe in vb6, so if anybody already knows how to do this in vb6 it would save me time.