Want to have vbscript execute series of commands sequentially

Posted on 2008-11-08
Last Modified: 2012-05-05
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 ("") "c:\VerBuild\VerGen.exe"
set wshshell = nothing
msgbox "Done executing program"
Question by:smm57
    LVL 65

    Accepted Solution

    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 ("") "c:\VerBuild\VerGen.exe", 1, True
    set wshshell = nothing
    msgbox "Done executing program"

    Open in new window

    LVL 14

    Assisted Solution

    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;"""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

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
    This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
    Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now