Interactive PowerBasic Forum

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Source Code => Scripting => Windows Script Host => Topic started by: José Roca on July 14, 2008, 06:52:31 PM

Title: IWshNetwork.SetDefaultPrinter Method
Post by: José Roca on July 14, 2008, 06:52:31 PM


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