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 andGetObject methods; the former method creates a new instance of an object, while the latter retrieves a reference to an existing instance. As Table 7-30 shows, using these methods, you can instantiate objects like the following:
Active Directory Service Interface (ADSI)
ADSI provides a single set of directory service interfaces for managing network resources.
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 and the Jet database engine. Its top-level object is named DBEngine.
The Dictionary object
A part of the Scripting Runtime Library, theDictionary object provides access to data sets that have identifiable keys.
The Excel Application object
The Excel object model is useful for extracting data from spreadsheets or for manipulating charts. Its top-level object is the Application object.
The FileSystemObject object
A part of the Scripting Runtime Library, the FileSystemObject provides access to the local filesystem.
Windows Management Instrumentation (WMI)
WMI is Microsoft's implementation of Web-Based Enterprise Management (WBEM), a technology that aims at standardizing access to management information in an enterprise environment.
The Word Application object
The Word object model makes it easy to manipulate Word .doc files as well as Rich Text Format (.rtf) files. Note that its top-level object is the Application object.
Object |
ProgID |
Description |
---|---|---|
Access |
Access.Application |
The forms and reports (primarily) of an Access table |
Connection |
ADODB.Connection |
An ADO database connection |
DBEngine |
DAO.DBEngine |
The DAO object model, primarily for Access databases |
Dictionary |
Scripting.Dictionary |
A high-performance alternative to arrays and collections for keyed data |
Excel |
Excel.Application |
The Microsoft Excel application, for manipulating spreadsheets and charts |
FileSystemObject |
Scripting.FileSystemObject |
Represents the local filesystem |
Recordset |
ADODB.Recordset |
An ADO recordset |
Session |
MAPI.Session |
A Session object using Collaborative Data Objects (CDO) |
SWbemLocator |
WbemScripting.SWbemLocator |
A WMI object that provides access to WMI on a particular local or remote host computer |
SWbemObjectPath |
WbemScripting.SWbemObjectPath |
A WMI object that constructs and validates object paths |
SWbemServices |
winmgmts: |
A WMI object whose InstancesOf method provides access to WMI class instances |
Word |
Word.Application |
The Microsoft Word application for manipulating documents |