Jump to content

Find IP address from printer name


Recommended Posts

How can I find the IPv4 address of a printer from its name, e.g. Lexmark CS310 ?

To be more precise: the printer shows in Devices and Printers as Lexmark CS310 updated. This is the only Lexmark on my LAN, so finding the IP for Lexmark would be OK for me.

I am trying to overcome the problem where the IP address of the printer changes, with a short script.

I have searched the forum. I found lots on networking, but nothing for this specific problem.

Edited by c.haslam
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

Using Printer Management UDF :

#include "PrintMgr.au3"

Local $aPrinterProperties = _PrintMgr_EnumPrinterProperties("Lexmark CS310")
If Not UBound($aPrinterProperties) Then Exit MsgBox(16, "Error", "Printer not found")

Local $sPortName = $aPrinterProperties[0][60]

Local $aTCPIPPorts = _PrintMgr_EnumTCPIPPrinterPort(), $sIP
For $i = 0 To UBound($aTCPIPPorts) - 1
    If $sPortName = $aTCPIPPorts[$i][0] Then $sIP = $aTCPIPPorts[$i][1]
Next

ConsoleWrite(   ($sIP ? "IP address of the printer : " & $sIP : "Unable to find the printer IP address") )

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...