Link to home
Start Free TrialLog in
Avatar of mgjust
mgjust

asked on

A method to cue multiple script sequential execution.

Hello,
Is there a way to have scripts run sequentially with just one act of execution (pardon my jargon or lack thereof)? To be clear: Have a script execute only after the previous has finished?

Thanks,
MJ
SOLUTION
Avatar of MrNevaj
MrNevaj

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Robberbaron (robr)
Robberbaron (robr)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, you can use a call to this VBS to wait for one or multiple batch files to finish:

'===================
'MUST BE RUN BY: START /WAIT RunAndWait.vbs script1.vbs script2.vbs
If WScript.Arguments.Count > 0 Then
      strWhileCondition = "Do Until "
      Set wshShell = CreateObject("WScript.Shell")
      For intArgNum = 0 To WScript.Arguments.Count - 1
            strCodeToExec = "Set objExec" & intArgNum & " = wshShell.Exec(""wscript.exe " & WScript.Arguments(intArgNum) & """)"
            Execute strCodeToExec
            If intArgNum < WScript.Arguments.Count - 1 Then
                  strWhileCondition = strWhileCondition & "objExec" & intArgNum & ".Status AND "
            Else
                  strWhileCondition = strWhileCondition & "objExec" & intArgNum & ".Status"
            End If
      Next
      strWhileCondition = strWhileCondition & VbCrLf & "WScript.Sleep 500" & VbCrLf & "Loop"
      'MsgBox strWhileCondition
      Execute strWhileCondition
End If
'===================

And you can use it in a batch file like this:

@echo off
start /wait RunAndWait.vbs file1.vbs file2.vbs file3.vbs
start /wait RunAndWait.vbs file4.vbs

Regards,

Rob.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mgjust
mgjust

ASKER

Thank you kindly.