The following code uses the
AddWindowsPrinterConnection method to connect a network printer to a Windows NT/2000 computer system.
JScript
var WshNetwork = WScript.CreateObject("WScript.Network");
var PrinterPath = "\\\\printserv\\DefaultPrinter";
WshNetwork.AddWindowsPrinterConnection(PrinterPath);
VBScript
Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printserv\DefaultPrinter"
WshNetwork.AddWindowsPrinterConnection PrinterPath
PowerBASIC
DIM pWshNet2 AS IWshNetwork2
DIM strPrinterPath AS STRING
pWshNet2 = NEWCOM "WScript.Network"
strPrinterPath = UCODE$("\\printserv\DefaultPrinter")
pWshNet2.AddWindowsPrinterConnection strPrinterPath