Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Understanding VBS 'True' & 'False' parameters

Posted on 2013-01-08
3
Medium Priority
?
790 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 2000 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 71

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

782 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