WshNetwork.RemovePrinterConnection
The RemovePrinterConnection method removes the current resource connection denoted by strName.
Syntax
WshNetwork.RemovePrinterConnection strName, [bForce], [bUpdateProfile]
Parameters
-
strName
-
The strName parameter can be either a local name or a remote name, depending on how the printer is connected. If the printer has a mapping between a local name (for example, LPT1) and a remote name, then strName must be set to the local name. If the network path does not have a local name mapping, then strName must be set to the remote name.
-
bForce
-
If bForce is supplied and its value is TRUE, this method removes the connection whether the resource is used or not.
-
bUpdateProfile
-
If bUpdateProfile is supplied and its value is TRUE, this mapping is stored in the user profile.
Example
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
' Local name mapped to remote share
WshNetwork.RemovePrinterConnection "LPT1:"
' No local name mapping. e.g. NET USE "\\Server\Printer1"
WshNetwork.RemovePrinterConnection "\\Server\Printer1"