AddPrinterConnection Method

Adds a remote MS-DOS-based printer connection to your computer system.

Syntax

object.AddPrinterConnection(strLocalName, strRemoteName[,bUpdateProfile][,strUser][,strPassword])

Arguments

  • object
    WshNetwork object.

  • strLocalName
    Sting value indicating the local name to assign to the connected printer.

  • strRemoteName
    Sting value indicating the name of the remote printer.

  • bUpdateProfile
    Optional. Boolean value indicating whether the printer mapping is stored in the current user's profile. If bUpdateProfile is supplied and is true, the mapping is stored in the user profile. The default value is false.

  • strUser
    Optional. String value indicating the user name. If you are mapping a remote printer using the profile of someone other than current user, you can specify strUser and strPassword.

  • strPassword
    Optional. String value indicating the user password. If you are mapping a remote printer using the profile of someone other than current user, you can specify strUser and strPassword.

Remarks

The AddPrinterConnection method adds a network printer to an MS-DOS printer port, such as LPT1. You cannot use this method to add a remote Windows-based printer connection. To add a remote Windows-based printer connection, use the AddWindowsPrinterConnection method.

Legacy Code Example

The following code uses the AddPrinterConnection method to connect a network printer to LPT1.

Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.AddPrinterConnection "LPT1", "\\Server\Print1"
var WshNetwork = WScript.CreateObject("WScript.Network");
WshNetwork.AddPrinterConnection ("LPT1", "\\\\Server\\Print1");

Applies To:

WshNetwork Object

See Also

AddWindowsPrinterConnection Method
EnumPrinterConnections Method
RemovePrinterConnection Method
SetDefaultPrinter Method