WSH » wshnetwork » RemovePrinterConnection

Syntax:
WshNetwork.RemovePrinterConnection (strName, [,bForce] [,bUpdateProfile])
strName
Receives the name of a previously mapped network printer to be removed.
bForce
If this optional parameter is set to True, then this method will remove the connection even if the resource is currently being used.
bUpdateProfile
If this optional parameter is set to True, the mapping will be removed from the current user's profile.

The RemovePrinterConnection method removes a previously connected netword printer.

The RemovePrinterConnection method removes a previously mapped network printer identified as strName. Depending on how the printer was connected, strName can be either a local name or a remote name. If the printer has a mapping between a local name and a remote name, then strName must be set to the local name. If the network printer does not have a local name mapping, then strName must be set to the remote name.

If the optional parameter bForce is set to True (default is False), then this method will remove the connection, even if the resource is currently being used. If the optional parameter bUpdateProfile is set to True (default is False), the mapping will be removed from current user's profile.

Examples

Code:
Set WshNetwork = CreateObject("WScript.Network")

WshNetwork.AddPrinterConnection "LPT1:", "\\Server\LaserJet"
WshNetwork.RemovePrinterConnection "LPT1:"

WshNetwork.AddWindowsPrinterConnection "\\Server\LaserJet"
WshNetwork.RemovePrinterConnection "\\Server\LaserJet"
Explanation:

This VBScript code demonstrates how to remove a connected network printer.

Language(s): VBScript