Solved

Understanding VBS 'True' & 'False' parameters

Posted on 2013-01-08
3
562 Views
Last Modified: 2013-01-08
Here's my two lines in code:

intErr = objShell.Run("cscript.exe ""D:\sample.vbs""", 0, True)
      
intErr = objShell.Run("D:\sample.bat", 0, False)

I was told the 'True' or 'False' is to tell it whether or not to finish the script before continuing on the 2nd one.  However on the first one, I was told it was to 'overwrite' the existing files if they exist.  Or am I misled.  I need to understand what differences are in the above.  I mainly need the first one to complete before it continues to the second one.
0
Comment
Question by:elwayisgod
3 Comments
 
LVL 13

Accepted Solution

by:
Surone1 earned 500 total points
ID: 38755403
objShell.Run (strCommand, [intWindowStyle], [bWaitOnReturn])

bWaitOnReturn : Wait for the command to complete before
                   continuing execution of the wsh script.

If bWaitOnReturn is set to TRUE, the Run method returns any error code returned by the application.

If bWaitOnReturn is not specified or FALSE, this method immediately returns to script execution rather than waiting on the process termination (and returns an error code of 0)

Specifying the bWaitOnReturn parameter allows you to run programs synchronously (one at a time).


http://ss64.com/vb/run.html


so if you use true the code will wait till the program or batch file exits before it continues with the next task. it has nothing to do with overwriting .
0
 

Author Comment

by:elwayisgod
ID: 38755407
That's what I thought because how would it know what my 'sample.vbs' is performing anyways.

Thanks,
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 38755413
See http://ss64.com/vb/run.html (for example) for reference. The last value of Shell.Run tells whether the call should wait for termination of the process.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

12 Experts available now in Live!

Get 1:1 Help Now