AddPrinterConnection Method of the Win32_Printer Class

The AddPrinterConnection WMI class method provides a connection to an existing printer on the network, and adds it to the list of available printers.

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

Syntax

MOF
uint32 AddPrinterConnection(
  [in]  string Name
);

Parameters

Name [in]

Friendly name for the printer.

Return Value

Returns one of the values listed in the following table, or any other value to indicate an error.

Return codeDescription
0

Success

5

Access Denied

1801

Invalid Printer Name

1930

Incompatible Printer Driver

 

Examples

For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.

For C++ code examples, see WMI C++ Application Examples.

Requirements

Minimum supported clientWindows XP
Minimum supported serverWindows Server 2003
MOFCimwin32.mof
DLLCimwin32.dll
Namespace\root\cimv2

See Also

Computer System Hardware Classes
Win32_Printer

Send comments about this topic to Microsoft

Build date: 11/3/2009

Tags :


Community Content

Isidoros
How to add a local printer?
After a LOT OF search i found a .NET solution.
The following example adds a printer to your system.

Dim strPrinterName as String = "Isidoros Printer"

Dim strComputer AsString = My.Computer.Name

Dim objWMIService, objPrinter AsObject

objWMIService = GetObject(

"winmgmts:" _

&

"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

objPrinter = objWMIService.Get(

"Win32_Printer").SpawnInstance_

objPrinter.Name = strPrinterName
objPrinter.DriverName = "Generic / Text Only"

objPrinter.PortName =

"c:\temp\file.prn"

objPrinter.DeviceID = strPrinterName

'objPrinter.Location = "Athens, Greece"

objPrinter.Network =

False

objPrinter.Shared =

False

'objPrinter.ShareName = "MyShareName"

objPrinter.Put_()

Hope that helps!
Isidoros (MCTS)
Athens, Greece


Page view tracker