Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Scripting
Windows Script Host
 SetDefaultPrinter Method
This page is specific to
.NET Framework 3.0

Other versions are also available for the following:
Windows Script Host
SetDefaultPrinter Method

Updated: November 2007

Assigns a remote printer the role Default Printer.

object.SetDefaultPrinter(strPrinterName)
object

WshNetwork object.

strPrinterName

String value indicating the remote printer's UNC name.

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.

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
JScript
var WshNetwork = WScript.CreateObject("WScript.Network");
var PrinterPath = "\\\\research\\library1";
WshNetwork.AddWindowsPrinterConnection(PrinterPath);
WshNetwork.SetDefaultPrinter(PrinterPath);

Applies To:

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker