Chapter 9. Windows Script Components

Windows Script Components (WSC) is a technology that allows programmers using scripting languages like VBScript to create COM components (that is, components based on Microsoft’s Component Object Model technology). Ordinarily, COM component creation requires a compiled programming language, such as C++ or Visual Basic. Windows Script Components relies on a runtime module (scrobj.dll ) that handles the implementation details of COM, while a script file parsed by the script engine contains the component definition.

The source code for a script component is stored in a Windows Script Component (.wsc ) file. This is an XML file that contains the component definition, along with the code for the properties, methods, and events that the component exposes.

In addition, Windows Script Components supports interface handlers , which are compiled COM components that provide the implementation for particular interfaces. Windows Script Components automatically provides support for the interfaces necessary for COM automation, ASP, and DHTML.

Windows Scripts Components automates much of the process of creating a COM component by providing a wizard that collects information on the component to be created and writes it to a .wsc file. To illustrate the operation of the wizard, we’ll create a simple math component.

The Script Component Wizard

The opening screen of the Script Component Wizard is shown in Figure 9-1. Although the dialog contains a number of text ...

Get VBScript in a Nutshell, 2nd Edition 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.