How to create a printerqueu with .NET and WMI
This is an example of how you create a printerqueue with .NET and WMI (Windows Management Instrumentation).
A list of properties can be found at MSDN Win32_Printer
Other topics:
How to install printerdrivers with wmi and VB.NET
How to create TCP/IP printerports with .NET
Imports System.Management
Dim shared as Boolean = true
Try
Dim mp As ManagementPath = New ManagementPath("Win32_Printer")
Dim co As ConnectionOptions = New ConnectionOptions()
co.EnablePrivileges = True
co.Impersonation = ImpersonationLevel.Impersonate
Dim ms As ManagementScope = New ManagementScope("\\" + Environment.MachineName + "\root\cimv2", co)
Dim printerObject As ManagementObject = New ManagementClass(ms, mp, Nothing).CreateInstance()
printerObject("PortName") = "IP_192.168.0.2"
printerObject("DriverName") = "DriverName"
printerObject("DeviceID") = "queuename"
printerObject("Location") = "Placement of printer"
printerObject("Comment") = "Some comments"
If (shared) Then
printerObject("Shared") = True
printerObject("ShareName") = "Sharename"
'printerObject("Published") = False ' Publish printer
End If
Dim options As PutOptions = New PutOptions()
options.Type = PutType.UpdateOrCreate
printerObject.Put(options)
Catch ex As Exception
' Do something
End Try
2 Comments
Install printerdrivers with WMI and VB.NET | Marcus Nyberg on januari 12th, 2010
[...] Other topics: How to install printerports with WMI and VB.NET How to create a printerqueu with .NET and WMI [...]

Install printerports with WMI and VB.NET | Marcus Nyberg on januari 12th, 2010
[...] Other topics: How to install printerdrivers with wmi and VB.NET How to create a printerqueu with .NET and WMI [...]