Accessing Other Object Models

On the whole, the functionality of WSH is strictly limited. For instance, WSH itself provides almost no access to the filesystem, nor does it support any application services. This is a deliberate omission; the designers of Windows Script Host intended that you could draw on the functionality of other object models when writing WSH scripts.

The “hooks” into other object models are provided by the WScript object’s CreateObject and GetObject methods; the former method creates a new instance of an object, while the latter retrieves a reference to an existing instance. As Table 7.25 shows, using these methods, you can instantiate objects like the following:

ActiveX Data Objects (ADO)

ADO is a data access technology that offers a uniform methodology for accessing data regardless of location or format. ADO has a relatively “flat” object model, and many objects (like the Recordset object, or the Connection object) can be instantiated independently of one another.

Collaborative Data Objects (CDO)

CDO is an object model that uses MAPI to create mail-enabled applications. The Session object is its top-level object.

Data Access Objects (DAO)

DAO is a data access technology intended primarily for use with Access databases. Its top-level object is named DBEngine.

The Dictionary object

A part of the Scripting Runtime Library, the Dictionary object provides high-performance access to data sets that have identifiable keys.

The Excel Application object

The Excel object model ...

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.