Click to Get Visto...It's FREE!

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!

jobEngine

 
  Categories:
Scripting Languages
Windows 95/NT
Operating Systems
The Windows Scripting Host
The WshShell and WshNetwork Objects

Continued from The Windows Scripting Host Object Model

The only two objects in the Windows Scripting Host object model that you can create directly are WshShell and WshNetwork; the rest are obtained by calling methods of WshShell and WshNetwork. For instance, if you wanted to create a new WshShortcut object, you would use the following VBScript code:

Dim WshShortcut

Set WshShortcut = WshShell
.CreateShortcut ("c:\shortcut.lnk")

WshShell performs a number of useful shell-related tasks. It retrieves information about the machine, such as processor type, number of processors, and OS version number. WshShell can also return the path to special folders, such as those for the desktop or Start menu. There are even methods for creating, modifying, and deleting Registry entries. The WshShell.Popup method presents the user with a dialog box that you can use to obtain simple yes/no answers from the user. The scripting language you use will probably have functions to handle more complex interactions with the user.

If you need to deal with network drives or network printers, you'll need to use the WshNetwork object, which has functions to handle mapping and disconnection. WshNetwork can also enumerate all the currently mapped network drives and printers. It does this with the methods EnumNetworkDrives and EnumPrinterConnections, both of which return WshCollection objects. WshCollection can be obtained only by calling the two enumeration functions in WshNetwork, and it is exactly what the name would suggest--a collection of items, either network drives or network printers.

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.