The Windows Scripting Host
The Windows Scripting Host Object Model
Continued from Active Scripting
Every Active Scripting host must expose some functionality that scripts will act upon, which is referred to as the host's object model. As you might expect, the Windows Scripting Host's object model exposes several objects that can be used to access different components of the Windows shell, such as shortcuts, network drives, and network printers.
The WScript object is the heart of the Windows Scripting Host object model. One instance of this object is always available, and it is always named WScript. WScript is used to obtain information about the currently running script and the Windows Scripting Host itself. It creates every object used by a script in the Windows Scripting Host, either directly or indirectly. The method used to create new objects is, unsurprisingly, CreateObject. To create a WshShell object in VBScript, you'd make a call like this:
Dim WshShell
Set WshShell = WScript
.CreateObject("WScript
.Shell")
It is also important to note that the CreateObject function can be used to create OLE Automation objects as well as Windows Scripting Host objects; this means that you can use the Windows Scripting Host to script any application that supports OLE Automation. Some of the samples included with the Windows Scripting Host use data read from an Excel spreadsheet (using Excel's OLE Automation interface) to add and remove users in the Windows NT Directory Service. There are many interesting and powerful ways to use this kind of scripting functionality, particularly for IS folks.
Continues. . .
Published as Operating Systems in the 02/10/98 issue of PC Magazine.