Removes a shared network printer connection from your computer system.
|
---|
object.RemovePrinterConnection(strName, [bForce], [bUpdateProfile]) |
Arguments
- object
WshNetwork object.
- strName
String value indicating the name that identifies the printer. It can be a UNC name (in the form \\xxx\yyy) or a local name (such as LPT1).
- bForce
Optional. Boolean value indicating whether to force the removal of the mapped printer. If set to true (the default is false), the printer connection is removed whether or not a user is connected.
- bUpdateProfile
Optional. Boolean value. If set to true (the default is false), the change is saved in the user's profile.
Remarks
Example
The following code disconnects a network printer.
Visual Basic Script | Copy Code |
---|
Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printserv\DefaultPrinter"
WshNetwork.RemovePrinterConnection PrinterPath, true, true |
JScript | Copy Code |
---|
var WshNetwork = WScript.CreateObject("WScript.Network");
var PrinterPath = "\\\\PRN-CORP1\\B41-4523-A";
WshNetwork.RemovePrinterConnection(PrinterPath, true, true); |
See Also