Remove a shared network printer connection.
Syntax
myObject.RemovePrinterConnection(strName, [bForce], [bUpdateProfile])
Arguments
strName : The printer name. It can be a UNC name, or a local name (such as LPT1).
bForce : Force the removal of the mapped printer.
(Boolean Optional, default = false).
bUpdateProfile : Save changes in the user's profile
(Boolean Optional, default = false)
Example
' Disconnect a network printer
Set PrinterPath = "\\printserv\MyPrinter"
WshNetwork.RemovePrinterConnection (PrinterPath, true, true)
Notes:
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.
"Law: Once you eliminate your #1 problem, #2 gets a promotion"
- Gerald
Weinberg, "The Secrets of Consulting"
Related commands:
Printer, add printer - WshNetwork.AddPrinterConnection
Printer, add Network printer - WshNetwork.AddWindowsPrinterConnection
Printer, list printers - WshNetwork.EnumPrinterConnections
Printer, set default printer - WshNetwork.SetDefaultPrinter
Equivalent Windows CMD command: CON2PRT - Connect or disconnect a Printer