將基于 MS-DOS 的遠程打印機連接添加到計算機系統(tǒng)中。
object.AddPrinterConnection(strLocalName, strRemoteName[,bUpdateProfile][,strUser][,strPassword])
AddPrinterConnection 方法將網(wǎng)絡打印機添加到 MS-DOS 打印機端口,如 LPT1。不能利用該方法添加基于 Windows 的遠程打印機連接。要添加基于 Windows 的遠程打印機連接,請使用 AddWindowsPrinterConnection 方法。
以下代碼使用 AddPrinterConnection 方法將網(wǎng)絡打印機連接到 LPT1。
Set WshNetwork = WScript.CreateObject("WScript.Network") WshNetwork.AddPrinterConnection "LPT1", "\\Server\Print1"
var WshNetwork = WScript.CreateObject("WScript.Network");
WshNetwork.AddPrinterConnection
("LPT1", "\\\\Server\\Print1");
WshNetwork 對象 | AddWindowsPrinterConnection 方法 | EnumPrinterConnections 方法 | RemovePrinterConnection 方法 | SetDefaultPrinter 方法