• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1496
  • Last Modified:

Get IP address of network printer (once mapped)? VB.NET 2003 (pref) / 2010 Exp

Hi Experts,

Is it possible to get a network printers IP Address once mapped to my machine?

1. I map printer through run \\print server\printername
2. I would like to (either) specifiy a single printer through its UNC path or
just interigate all mapped printers and have them show in textbox on my WINDFORM.

I'm getting tired having to delv through printer properties for port data :(

I searched through several web articals:


... but i guess i need an expert - right ;)

I found the following code below, but I'm not sure how it make it work with what i'm trying to do.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ' Example of how to use this subroutine:
        AddNetworkPrinter("HP LaserJet 1320 PCL 6", "//myserver/Printer", True, True)
    End Sub

    ''' <summary>
    ''' Adds a Network Printer to the computer
    ''' </summary>
    ''' <param name="printerName">Name of the Printer you'd like to add</param>
    ''' <param name="networkPath">The path of the networked printer</param>
    ''' <param name="useExistingDriver">Don't overwrite existing driver</param>
    ''' <param name="setDefaultPrinter">Set as the default printer</param>
    ''' <remarks></remarks>

    Public Shared Sub AddNetworkPrinter(ByRef printerName As String, ByRef networkPath As String, _
     Optional ByRef useExistingDriver As Boolean = 0, Optional ByRef setDefaultPrinter As Boolean = 0)

        Dim cmdToSend As String = "rundll32 printui.dll,PrintUIEntry /in /m " & Chr(34) & printerName & Chr(34) & " /f " & networkPath
        If useExistingDriver Then cmdToSend += " /u" '  /u = use the existing printer driver if it's already installed
        If setDefaultPrinter Then cmdToSend += " /y" '  /y = set printer as the default
        Shell(cmdToSend, AppWinStyle.Hide) ' execute the command

    End Sub

Open in new window

  • 5
  • 4
1 Solution
The title and description do not match. Do you want to get the IP of connected printer or do you want to connect to a network printer?
RobertoFreemanoAuthor Commented:
Hi CodeCruiser,

Sorry for the confusion: Get IP of connected printer please CodeCruiser but if possible connect to a network printer too ;)
RobertoFreemanoAuthor Commented:
1. Get IP of connected printer please
2. if possible, connect to a network printer too ;)
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

RobertoFreemanoAuthor Commented:
Gosh! It's a bit over my head ...
RobertoFreemanoAuthor Commented:
Thanks CodeCruiser,

I have a few ideas but will need to take into the office to test... brb ;)
are you wanting to just get the ip address?

just command prompt

ping UNCprintername

and it should return the ip address of said printer... if within the same subnet/network
... might not be able to do this across domains...
RobertoFreemanoAuthor Commented:
Thanks CC ;)
Glad to help :-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now