O'Reilly logo

VBScript in a Nutshell by Ron Petrusha, Paul Lomax, Matt Childs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required