Making Decisions

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

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.


send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net