Removes a shared network printer connection from your computer system.
The RemovePrinterConnection method removes both Windows and MS-DOS based printer connections. If the printer was connected using the method AddPrinterConnection, strName must be the printer's local name. If the printer was connected using the AddWindowsPrinterConnection method or was added manually (using the Add Printer wizard), then strName must be the printer's UNC name.
The following code disconnects a network printer.
Set WshNetwork = WScript.CreateObject("WScript.Network") PrinterPath = "\\printserv\DefaultPrinter" WshNetwork.RemovePrinterConnection PrinterPath, true, true
var WshNetwork = WScript.CreateObject("WScript.Network"); var PrinterPath = "\\\\PRN-CORP1\\B41-4523-A"; WshNetwork.RemovePrinterConnection(PrinterPath, true, true);