The following code uses the
AddWindowsPrinterConnection method to connect a network printer and set it as the default printer.
JScript
var WshNetwork = WScript.CreateObject("WScript.Network");
var PrinterPath = "\\\\research\\library1";
WshNetwork.AddWindowsPrinterConnection(PrinterPath);
WshNetwork.SetDefaultPrinter(PrinterPath);
VBScript
Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\research\library1"
WshNetwork.AddWindowsPrinterConnection PrinterPath
WshNetwork.SetDefaultPrinter PrinterPath
PowerBASIC
DIM pWshNet2 AS IWshNetwork2
DIM strPrinterPath AS STRING
strPrinterPath = UCODE$("\\research\library1")
pWshNet = NEWCOM "WScript.Network"
pWshNet.AddWindowsPrinterConnection strPrinterPath
pWshNet.SetDefaultPrinter strPrinterPath