Method:  WshNetwork.AddWindowsPrinterConnection

Win 95/98: WshNetwork.AddWindowsPrinterConnection strPrinterPath, strDriverName [,strPort]
 
Win2000/NT: WshNetwork.AddWindowsPrinterConnection strPrinterPath

There are two prototypes of the AddWindowsPrinterConnection method, one for Windows 95/98, and one for Windows NT/2000. This method essentially emulates the process of adding network printer connections via Control Panel/Printers. When using this method on Windows 95/98 machines, the printer driver must already be installed or this method will fail. Unlike the AddPrinterConnection method, this method does not require a port to be specified explicitly. The default port is LPT1.

The following VBScript code connects to the network printer \\Server\LaserJet.

Code:
' On Windows 95/98 Machines:
strPrinterPath = "\\Server\LaserJet"
strDriverName = "HP LaserJet 4/4M Plus PS 600"
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection strPrinterPath, strDriverName


' On Windows NT/2000 Machines:
strPrinterPath = "\\Server\LaserJet"
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection strPrinterPath

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