• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1280
  • Last Modified:

Want to have vbscript execute series of commands sequentially

I am a newbie to vbscripting... I want to have a .vbs file, when invoked at the command line, start a VB program .exe I wrote and "wait" for it to finish before proceeding further. The VB program writes a bunch of fortran source files that I will subsequently use in a Visual Fortran in the MSdev environment to create a new msdev based visual fortran project. I then want to be able to create a VStudio session object so as to be able to manipulate an instance of the IDE using these newly created files. I will also want to set several configuration aspects of the project via the above mentioned session object as well, but this is beyond the scope of this question.

The important point here is that I want to have vbscript operate on "my commands" sequentially....

I know this is not the default behavior because when I run the following vbs commands in a .vbs file the msgbox pops up way before my executable finishes, thanks in advance for any help.....

Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run "c:\VerBuild\VerGen.exe"
set wshshell = nothing
msgbox "Done executing program"
2 Solutions
Hi, have you tried adding a third parameter to the Run method, which will make the script wait for VerGen.exe to finish?



Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run "c:\VerBuild\VerGen.exe", 1, True
set wshshell = nothing
msgbox "Done executing program"

Open in new window

I would just like to add that if your file name has a space in it, please update line 2 above to look like the following;
WSHShell.run("""c:\Program Files\VerBuild\VerGen.exe""", 1, true)
It may look strange but all the quotes are necessary to handle spaces in the file path/name.
I know it may not be necessary for this example, I just wanted to add that in case you were to run other exe's later in your script that may be from other folders.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now