• Welcome to Theos PowerBasic Museum 2017.

IWshNetwork.SetDefaultPrinter Method

Started by José Roca, July 14, 2008, 06:52:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



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