Compaq. Better Answers.

PC Magazine

  PC Tech

The Windows Scripting Host

Introduction

Active Scripting

The Windows Scripting Host Object Model

The WshShell and WshNetwork Objects

Putting It Together

Figure 1: Mapping Network Drives

Figure 2: Creating URL Shortcuts



X10.com - The SuperSite for Home Automation!

Free training at MicronU

 
  Categories:
Scripting Languages
Windows 95/NT
Operating Systems
The Windows Scripting Host
The Windows Scripting Host Object Model

Continued from Active Scripting

Every Active Scripting host must expose some functionality that scripts will act upon, which is referred to as the host's object model. As you might expect, the Windows Scripting Host's object model exposes several objects that can be used to access different components of the Windows shell, such as shortcuts, network drives, and network printers.

The WScript object is the heart of the Windows Scripting Host object model. One instance of this object is always available, and it is always named WScript. WScript is used to obtain information about the currently running script and the Windows Scripting Host itself. It creates every object used by a script in the Windows Scripting Host, either directly or indirectly. The method used to create new objects is, unsurprisingly, CreateObject. To create a WshShell object in VBScript, you'd make a call like this:

Dim WshShell
Set WshShell = WScript
.CreateObject("WScript
.Shell")

It is also important to note that the CreateObject function can be used to create OLE Automation objects as well as Windows Scripting Host objects; this means that you can use the Windows Scripting Host to script any application that supports OLE Automation. Some of the samples included with the Windows Scripting Host use data read from an Excel spreadsheet (using Excel's OLE Automation interface) to add and remove users in the Windows NT Directory Service. There are many interesting and powerful ways to use this kind of scripting functionality, particularly for IS folks.

Continues. . .

Published as Operating Systems in the 02/10/98 issue of PC Magazine.


 SPONSORED LINKS
@Backup   Your Solid Online Backup Plan. Download Now.
Services   9c/MINUTE LONG DISTANCE, 5c/MINUTE ON SUNDAYS!
STORAGE   Quantum means non-stop business, 24 hours a day
Software   X10.com -- The SuperSite for Home Automation
Books   Bargain Books up to 90% off at barnesandnoble.com
 ZDNET FEATURED LINKS
Downloads   Check out the best new downloads in Reviewer's Raves
Bargains!   Shop the Basement for best buys on computer products
Free Help   Got computing questions? ZDHelp has all the answers!
 MAGAZINE OFFERS
Free Offer   Get a FREE SUBSCRIPTION to Inter@ctive Week

TOP
Copyright (c) 1998 Ziff-Davis Inc.