Click here and be enlightened

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!

First USA!

 
  Categories:
Scripting Languages
Windows 95/NT
Operating Systems
The Windows Scripting Host
FIGURE 1

Continued from Putting It Together

This script reads a list of UNC names from a text file and maps a network drive to each name.

Dim WshNetwork
Dim fs, listFile
Dim nameString, driveNum, driveString

Set fs = WScript.CreateObject ("Scripting.FileSystemObject")
Set listFile = fs.OpenTextFile("c:\wsh\list.txt")

Set WshNetwork = WScript.CreateObject("WScript.Network")

Do While listFile.AtEndOfStream <> True

 nameString = listFile.ReadLine

 For driveNum = 26 to 5 Step -1
      driveString = Chr(driveNum + 64) & ":"
      On Error Resume Next
      WshNetwork.MapNetworkDrive driveString, nameString
      If Err.Number = 0 Then Exit For

 Next

 If driveNum <= 5 Then
      WshShell.Popup("No drive letters available.")

 End If

Loop

listFile.Close

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.