OBJECT:  WshNetwork

The WshNetwork object exposes the network functionalities of Microsoft Windows, making it easy to manage drives and printers on the network. The WshNetwork object is not instantiated automatically upon script execution, hence it must be instantiated explicitly using CreateObject before it can be used.

Through the WshNetwork object one can query some of the network related information about a local computer, connect to drives and printers on the network, map and unmap network drives, set default printer, and disconnect from drives and printers on the network.

PROPERTIES

ComputerName Property
The ComputerName property is read only and returns a string which is the current computer's name.

Syntax: WshNetwork.ComputerName

UserDomain Property
The UserDomain property is read only and returns a string which is the current user's domain name.

Syntax: WshNetwork.UserDomain

UserName Property
The UserName property is read only and returns a string which is the current user's name.

Syntax: WshNetwork.UserName


 
METHODS

AddPrinterConnection Method
The AddPrinterConnection method makes a connection to a remote printer.

Syntax: WshNetwork.AddPrinterConnection strLocalName, strRemoteName [,bUpdateProfile] [,strUser] [,strPassword]

AddWindowsPrinterConnection Method
The AddWindowsPrinterConnection method adds a printer connection to Windows. This method reqires different number of arguments depending on the version of Windows the script is running on.

Windows 95/98 Syntax: WshNetwork.AddPrinterConnection strPrinterPath, strDriverName [,strPort]

Windows NT/2000 Syntax: WshNetwork.AddPrinterConnection strPrinterPath

EnumNetworkDrives Method
The EnumNetworkDrives method returns a collection of the current network drive mappings.

Syntax: WshNetwork.EnumNetworkDrives()

EnumPrinterConnections Method
The EnumPrinterConnections method returns a collection of the current network printer mappings.

Syntax: WshNetwork.EnumPrinterConnections()

MapNetworkDrive Method
The MapNetworkDrive method maps a remote drive onto a local drive letter.

Syntax: WshNetwork.MapNetworkDrive strLocalName, strRemoteName [,bUpdateProfile] [,strUser] [,strPassword]

RemoveNetworkDrive Method
The RemoveNetworkDrive method removes a previously mapped network drive.

Syntax: WshNetwork.RemoveNetworkDrive strName [,bForce] [,bUpdateProfile]

RemovePrinterConnection Method
The RemovePrinterConnection method removes a previously connected netword printer.

Syntax: WshNetwork.RemovePrinterConnection strName [,bForce] [,bUpdateProfile]

SetDefaultPrinter Method
The SetDefaultPrinter method sets the default printer to the specified printer.
Syntax: WshNetwork.SetDefaultPrinter strPrinterName

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information