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"
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.