Install printerports with WMI and VB.NET
This is an example of how you install TCP/IP printerports with .NET and WMI (Windows Management Instrumentation).
A list of properties can be found at MSDN Win32_TCPIPPrinterPort
Other topics:
How to install printerdrivers with wmi and VB.NET
How to create a printerqueu with .NET and WMI
Imports System.Management
Try
Dim mp As ManagementPath = New ManagementPath("Win32_TCPIPPrinterPort")
Dim co As ConnectionOptions = New ConnectionOptions()
co.EnablePrivileges = True
Dim ms As ManagementScope = New ManagementScope("\\" + Environment.MachineName + "\root\cimv2", co)
Dim port As ManagementObject = New ManagementClass(ms, mp, Nothing).CreateInstance()
port.SetPropertyValue("Name", "portname")
port.SetPropertyValue("Protocol", 1)
port.SetPropertyValue("HostAddress", "10.15.12.12")
port.SetPropertyValue("PortNumber", "9100")
Dim po As PutOptions = New PutOptions()
po.UseAmendedQualifiers = True
po.Type = PutType.UpdateOrCreate
port.Put(po)
Catch ex As Exception
' do something
End Try
2 Comments
How to create a printerqueu with .NET and WMI | Marcus Nyberg on januari 12th, 2010
[...] Så köper du ett flipperspelmod_rewrite: could not init rewrite log lock in childConvert youtube-links in text to embedded flash playerInstall printerdrivers with WMI and VB.NETNagios check_nt over ssh-tunnelBash script that open and close an ssh-tunnel automagicallyFunäsdalen i påskInstall printerports with WMI and VB.NET [...]

Install printerdrivers with WMI and VB.NET | Marcus Nyberg on december 11th, 2009
[...] Other topics: How to install printerports with WMI and VB.NET [...]