Chapter 7. Windows Script Host

Windows Script Host (WSH), originally introduced as a dynamic link library included with Windows 98, also is available in standalone versions for Windows 95 and Windows NT.

WSH is designed to eliminate one of the major limitations of the Win32 platform: it has no real batch or macro language that allows common processes (such as creating shortcuts, writing to and reading from the registry, or getting information on the filesystem) to be automated. Windows’ predecessor, the character-based DOS operating system, for instance, included the DOS batch language. And Windows 3.0 included the idiosyncratic and unsuccessful Recorder, which allowed the user to “record” keystrokes and mouse clicks and later repeat them.

Like most Component Object Model (COM) objects, WSH is language independent. That is, it can be used with any scripting language that supports COM. The language most commonly used to write WSH scripts, however, is VBScript.

Windows Script Host actually consists of two separate programs. The first, WScript.exe , is the runtime engine for scripts that run within the Windows environment. The second, CScript.exe , is the runtime engine for scripts that execute within a console mode (or DOS) window.

Why Use WSH?

WSH exposes a relatively small but very significant portion of the functionality of the 32-bit Windows family of operating systems. In addition, WSH allows you to tap into other object models (such as the FileSystemObject object model provided ...

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.