Click here to Skip to main content
14,697,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to vb-scripting so this may be easy to do.

I am looking to make a script that will run all programs including VBS, exe, bat files in a specified folder.

I want to put the files in the folder and run this VBS that will then run all of the files.

It also needs to wait for each to finish before moving to the next file.

The more basic the better.

1 solution

Dim myFolder : myFolder = "c:\temp"

Set fso = CreateObject("Scripting.FileSystemObject")
Set sh = CreateObject("WScript.Shell")

For Each file In fso.GetFolder(myFolder).Files
    If Len(file.Name) > 5 Then
        Dim extension : extension = UCase(Right(file.Name, 3))
        Select Case extension
        Case "VBS":
            sh.Run "wscript """ & file.Path & """", 1, True
        Case "EXE":
        Case "BAT":
            sh.Run file.Path, 1, True
        End Select
    End If

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900