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.
Syntax: WshNetwork.ComputerName
The ComputerName property is read only and returns a string which is the current computer's name.
Syntax: WshNetwork.UserDomain
The UserDomain property is read only and returns a string which is the current user's domain name.
Syntax: WshNetwork.UserName
The UserName property is read only and returns a string which is the current user's name.
Syntax: WshNetwork.AddPrinterConnection (strLocalName, strRemoteName [,bUpdateProfile] [,strUser] [,strPassword])
The AddPrinterConnection method makes a connection to a remote printer.
Syntax: Win 95/98: WshNetwork.AddWindowsPrinterConnection(strPrinterPath, strDriverName
[,strPort])
Win2000/NT: WshNetwork.AddWindowsPrinterConnection (strPrinterPath)
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.
Syntax: WshNetwork.EnumNetworkDrives ()
The EnumNetworkDrives method returns a collection of the current network drive mappings.
Syntax: WshNetwork.EnumPrinterConnections ()
The EnumPrinterConnections method returns a collection of the current network printer mappings.
Syntax: WshNetwork.MapNetworkDrive (strLocalName, strRemoteName [,bUpdateProfile] [,strUser] [,strPassword])
The MapNetworkDrive method maps a remote drive onto a local drive letter.
Syntax: WshNetwork.RemoveNetworkDrive (strName, [,bForce] [,bUpdateProfile])
The RemoveNetworkDrive method removes a previously mapped network drive.
Syntax: WshNetwork.RemovePrinterConnection (strName, [,bForce] [,bUpdateProfile])
The RemovePrinterConnection method removes a previously connected netword printer.
Syntax: WshNetwork.SetDefaultPrinter (strPrinterName)
The SetDefaultPrinter method sets the default printer to the specified printer.