• Welcome to Theos PowerBasic Museum 2017.

IWshNetwork.RemovePrinterConnection Method

Started by José Roca, July 14, 2008, 06:55:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following code disconnects a network printer.

JScript


var WshNetwork = WScript.CreateObject("WScript.Network");
var PrinterPath = "\\\\PRN-CORP1\\B41-4523-A";
WshNetwork.RemovePrinterConnection(PrinterPath, true, true);


VBScript


Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printserv\DefaultPrinter"
WshNetwork.RemovePrinterConnection PrinterPath, true, true


PowerBASIC


DIM pWshNet AS IWshNetwork
DIM strPrinterPath AS STRING
DIM vForce AS VARIANT
DIM vUpdateProfile AS VARIANT
strPrinterPath = UCODE$("\\printserv\DefaultPrinter")
pWshNet = NEWCOM "WScript.Network"
vForce = %VARIANT_TRUE AS INTEGER
vUpdateProfile = %VARIANT_TRUE AS INTEGER
pWshNet.RemovePrinterConnection strPrinterPath, vForce, vUpdateProfile