All Properties
Method: WshNetwork.RemovePrinterConnection
WshNetwork.
RemovePrinterConnection
strName, [,bForce] [,bUpdateProfile]
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.
The following VBScript code demonstrates how to remove a connected network printer.
Code:
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddPrinterConnection "LPT1:", "\\Server\LaserJet"
WshNetwork.RemovePrinterConnection "LPT1:"
WshNetwork.AddWindowsPrinterConnection "\\Server\LaserJet"
WshNetwork.RemovePrinterConnection "\\Server\LaserJet"
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information