Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Components in the WSH environment must interact with one another to run scripts. These interactions include the following:
Script Host and Script File When a script host is invoked to run a script, it begins by examining the file-name extension of the script file. The script host searches the registry to determine the scripting language engine that corresponds to the extension and then loads the script file in preparation for interpreting its instructions. All this happens before a single line of code is actually executed.
Script Host and Scripting Language Engine After determining the language used in the script, the script host works with the corresponding scripting language engine to interpret the instructions in the script. The script host communicates with the scripting language engine through the Windows Script Interfaces. The entire script is read and checked for syntax errors before any code is executed. For example, the following script has an error in line 3; the syntax of the If Then statement is incorrect:
Wscript.Echo
"Line 1.
"Wscript.Echo
"Line 2.
"If x = 1 Wscript.Echo
"X is equal to 1.
"End If
You might expect that the script would execute lines 1 and 2 and thus display two messages before encountering the error on line 3. Instead, the error is caught in the pre-execution syntax check. Instead of displaying two messages, the script displays the error message "Expected Then ."
WScript Library and COM Objects When instructions within a script indicate that a COM object is to be used, the built-in WScript library interacts with the COM runtime on behalf of the script.
Note
Send us your feedback | « Previous | Next » |