tags:

views:

26

answers:

2

I have a couple of applications that I would like to execute one following the other.

how do I do this? I tried this but the second task never executed.

on error resume next
Set WshShell = CreateObject("WScript.Shell") 

WshShell.Run """C:\Program Files\my folder\do task1.exe.vbs"""

WshShell.Run """C:\Program Files\my folder\do task2.exe.vbs"""

msgbox "Finished tasks"

update: notes found on WshShell.Run click here

A: 

Try

'Place all of the following in a .vbs file
'

Sub RunApplication(ByVal sFile)
Dim shell

    Set WShell = CreateObject("WScript.Shell")
    WShell.Run Chr(34) & sFile & Chr(34), 1, false
    Set shell = Nothing
End Sub


'Executing apps.

RunApplication "C:\Program Files\my folder\task1.exe"
RunApplication "C:\Program Files\my folder\task1.exe"
Saif Khan
A: 

Hi,

The Run method of WScript.shell has an optional parameter that can halt execution of the script until the Run method returns.

Try:

WshShell.Run("""C:\YourPathTo\task1.exe""", 1, true)

The third parameter, true in the line above tells the interpreter to wait until this task exits before continuing to the next line of the script.

-isdi-

ISDi