Adds a Windows-based printer connection to your computer system.
|
---|
Windows NT/2000:
object.AddWindowsPrinterConnection(
strPrinterPath
) |
|
---|
Windows 9x/Me:
object.AddWindowsPrinterConnection(
strPrinterPath,
strDriverName[,strPort]
) |
Arguments
- object
WshNetwork object.
- strPrinterPath
String value indicating the path to the printer connection.
- strDriverName
String value indicating the name of the driver (ignored if used on Windows NT/Windows 2000).
- strPort
Optional. String value specifying a printer port for the printer connection (ignored on Windows NT/Windows 2000).
Remarks
Example 1
The following code uses the AddWindowsPrinterConnection method to connect a network printer to a Windows NT/2000 computer system.
Visual Basic Script | Copy Code |
---|
Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printserv\DefaultPrinter"
WshNetwork.AddWindowsPrinterConnection PrinterPath |
JScript | Copy Code |
---|
var WshNetwork = WScript.CreateObject("WScript.Network");
var PrinterPath = "\\\\printserv\\DefaultPrinter";
WshNetwork.AddWindowsPrinterConnection(PrinterPath); |
Example 2
The following code uses the AddWindowsPrinterConnection method to connect a network printer to a Windows 9x/Me computer system.
Visual Basic Script | Copy Code |
---|
Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printserv\DefaultPrinter"
PrinterDriver = "Lexmark Optra S 1650"
WshNetwork.AddWindowsPrinterConnection PrinterPath, PrinterDriver |
JScript | Copy Code |
---|
var WshNetwork = WScript.CreateObject("WScript.Network");
var PrinterPath = "\\\\printserv\\DefaultPrinter";
var PrinterDriver = "Lexmark Optra S 1650";
WshNetwork.AddWindowsPrinterConnection(PrinterPath, PrinterDriver); |
See Also