Reputation: 21
I'm trying to launch 2 VBS and 1 BATCH script all at the same time. So I would have 3 lines of code launching 3 things all at the same time without one having to wait for the other to finish.
I've tried a BATCH script to launch these 3 but I can't get it to work without it waiting for one process before it moves onto the next line of code.
I tried a VBS to launch these 3 but it tells me it can't find the file location if I have more than one line.
So which one would be more effective (or what type of any code would be most effective) and what would be the code to launch all 3?
Upvotes: 2
Views: 142
Reputation: 18837
In vbscript you can do something like that :
Option Explicit
Dim Vbsfile1,Vbsfile2,Batchfile
Vbsfile1 = "C:\HackooTest\Nouveau dossier\ConnectJob.vbs"
Vbsfile2 = "C:\HackooTest\Nouveau dossier\Calc.vbs"
Batchfile = "C:\HackooTest\Nouveau dossier\toto1.bat"
Call Launch(Vbsfile1)
Call Launch(Vbsfile2)
Call Launch(Batchfile)
'********************************************
Sub Launch(MyProgram)
Dim ws,Result
Set ws = CreateObject("wscript.Shell")
Result = ws.run(DblQuote(MyProgram),1,False)
End Sub
'********************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'********************************************
Upvotes: 1
Reputation: 57262
start "" cscript vbscript1.vbs
start "" cscript vbscript2.vbs
start "" batchFile.bat
Start command will start a process without waiting for its finish.
Upvotes: 1