Solved

Understanding VBS 'True' & 'False' parameters

Posted on 2013-01-08
3
569 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…

914 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

16 Experts available now in Live!

Get 1:1 Help Now