.RemovePrinterConnection

Remove a shared network printer connection.

Syntax 
      objNetwork.RemovePrinterConnection(strName, [bForce], [bUpdateProfile])

Key
   objNetwork : A WScript.network object

   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)

Examples

' Disconnect a network printer

Set PrinterPath = "\\printserv\MyPrinter"
Set objNetwork = WScript.CreateObject("WScript.Network") 
objNetwork.RemovePrinterConnection (PrinterPath, true, true)

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:

Printer, add printer - .AddPrinterConnection
Printer, add Network printer - .AddWindowsPrinterConnection
Printer, list printers - .EnumPrinterConnections
Printer, set default printer - .SetDefaultPrinter
PRNMNGR - Add, delete, list printers and printer connections.


 
Copyright © 1999-2024 SS64.com
Some rights reserved