Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Assigns a remote printer the role Default Printer.
Syntax
object.SetDefaultPrinter(strPrinterName)
Arguments
object
WshNetwork object.strPrinterName
String value indicating the remote printer's UNC name.
Remarks
The SetDefaultPrinter method fails when using a DOS-based printer connection. You cannot use the SetDefaultPrinter method to determine the name of the current default printer.
Legacy Code Example
The following code uses the AddWindowsPrinterConnection method to connect a network printer and set it as the default printer.
Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\research\library1"
WshNetwork.AddWindowsPrinterConnection PrinterPath
WshNetwork.SetDefaultPrinter PrinterPath
var WshNetwork = WScript.CreateObject("WScript.Network");
var PrinterPath = "\\\\research\\library1";
WshNetwork.AddWindowsPrinterConnection(PrinterPath);
WshNetwork.SetDefaultPrinter(PrinterPath);
Applies To:
See Also
AddPrinterConnection Method
AddWindowsPrinterConnection Method
EnumPrinterConnections Method
RemovePrinterConnection Method