Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

SetDefaultPrinter method of the Win32_Printer class

The SetDefaultPrinter WMI class method sets the default system printer for the user calling the method.

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.

Syntax


uint32 SetDefaultPrinter();

Parameters

This method has no parameters.

Examples

The Install a TCP/IP Printer Port and Printer VBScript sample installs a TCP/IP printer port, installs a printer, and then sets the printer to be default.

The following VBScript code sample sets the default printer on a computer.


strComputer = "." 
Set objWMIService = GetObject("winmgmts:" _ 
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
 
Set colInstalledPrinters =  objWMIService.ExecQuery _ 
    ("Select * from Win32_Printer Where Name = 'ScriptedPrinter'") 
 
For Each objPrinter in colInstalledPrinters 
    objPrinter.SetDefaultPrinter() 
Next 

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Namespace

\root\CIMV2

MOF

CIMWin32.mof

DLL

CIMWin32.dll

See also

Computer System Hardware Classes
WMI Tasks: Printers and Printing
Win32_Printer

 

 

Show:
© 2014 Microsoft