The WSH Object Model

When using VBScript to write WSH scripts, you use VBScript to access the WSH object model. The Windows Script Host object model is shown in Figure 7.1. It is a small and fairly shallow object model that consists of a single application-level object, the WScript object, along with two additional levels of child objects.

The Windows Scripting Host object model

Figure 7-1.  The Windows Scripting Host object model

WSH is not intended to be a self-contained, all-encompassing object model. It focuses on three major areas:

  • Providing resources necessary to support script execution. For instance, the WScript object reports on the interpreter and version of WSH in use, while the WshShell object allows shortcuts and Internet shortcuts to be created.

  • Enhancing the ease with which a system can connect to and disconnect from network resources. This functionality is supported by the WshNetwork object.

  • Supporting functionality that is not readily available in other object models. For example, the WshShell object allows access to environment variables and to the location of Windows system folders.

Through the CreateObject and GetObject methods of the WScript object, WSH allows you to take advantage of the functionality supported by other objects that support COM automation. This topic is discussed in Section 7.6 later in this chapter. The remainder of this section provides concise documentation on the objects that form ...

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.