Assign a remote printer the role Default Printer.
Syntax WshNetwork.SetDefaultPrinter(strPrinterName) Arguments strPrinterName : The remote printer's UNC name. Examples 'Set the Default Printer to \\research\library1 Dim WshNetwork Set WshNetwork = CreateObject("WScript.Network") WshNetwork.SetDefaultPrinter "\\research\library1" ' Connect to \\research\library1 and set it as the default. Set PrinterPath = "\\research\library1" Set WshNetwork = WScript.CreateObject("WScript.Network") Set rc = WshNetwork.AddWindowsPrinterConnection(PrinterPath) If Not rc then WScript.Echo("Printer Connection Failed!") End If WshNetwork.SetDefaultPrinter PrinterPath
Notes
This method fails when using a DOS-based printer connection. You cannot use
the SetDefaultPrinter method find out the name of the current default printer.
"People think that being famous is just about having your picture taken
all the time and being rich rich rich, and you know what?... They're absolutely
right." - Madonna
Related commands:
Printer, add printer - WshNetwork.AddPrinterConnection
Printer, add Network printer - WshNetwork.AddWindowsPrinterConnection
Equivalent Windows NT command:
NET VIEW - to view a list of printers
NET PRINT - View and Delete print jobs
PRNCNFG - Display, configure or rename a printer
PRNDRVR - Add, delete or list printer drivers.
PRNMNGR - Add, delete, or list printers / connections, set the default printer.
CON2PRT - Connect or disconnect a Printer