Export (0) Print
Expand All

Introduction to Making Decisions

Microsoft® Windows® 2000 Scripting Guide

Typically, VBScript runs a script in sequential order, running line 1, then line 2, and then line 3, continuing until it runs the last line and then automatically completes.

In general, this makes script writing easier; after a script has started, you can rely on VBScript to run each line in the proper order and then stop the script and release any memory that was allocated to run the script. At the same time, however, the fact that VBScript runs every line in a script introduces a complication: What happens if there are lines in the script that you do not want to run?

For example, suppose you have a script that backs up a set of files to a remote computer and then deletes the original files from the local computer. Provided there are no problems, you want the script to run each line. But what if the remote computer is unavailable? In that case, if the script runs each line, it will try to back up the files. This will fail because the remote computer is not available. It then deletes the original files, even though the backup was not successful. Unfortunately, the delete operation succeeds, and you lose the files.

In a case such as this, you want the script to check the condition is the remote computer available? and proceed only if the condition is True. This type of decision-making can be implemented by using If Then or Select case statements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft