0

Is there any way to gather Serial Number info for HP Printers on Windows using only the CMD? I don't need a third party tool. What I need is to be able to query them from CMD. For the workstations I use the [wmic /node:COMPUTER bios get serialnumber] command to get what I want. I was wondering if there's a way, a script of some kind that could perform the same action.

Thanks

WYSIWYG
  • 137
  • 2
  • 2
  • 7
  • 1
    This needs more information. Do you want VBA? VBScript? Command line? This isn't at all clear right now what you are asking. – enderland Apr 16 '14 at 13:14
  • I need VBA, as I mainly work in excel. But I would settle for anything that could gather the Serial Numbers of them network printers. – WYSIWYG Apr 17 '14 at 05:02

2 Answers2

0

I cannot find an option to include the serial number as it is not supported by the vbscript Win32_Printer class, however you may be able to retrieve unique information from this script.

Win32_Printer Class

Option Explicit

Dim objWMIService
Dim objItem
Dim colItems
Dim strComputer
DIm intPrinters

strComputer ="."


    ' Pure WMI Section
    Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Printer")



    ' On Error Resume Next
    For Each objItem In colItems

        If(objItem.name = "HP") Then

        WScript.Echo (objItem.name)
        WScript.Echo (objItem.Description) 
        WScript.Echo (objItem.DeviceID)
        WScript.Echo (objItem.DriverName)

        End If  

    Next

'Release Memory
Set objItem = Nothing
Set objWMIService = Nothing
Set colItems = Nothing

WScript.Quit
  • Thank you for your input here, but this does not meet my needs. I need to gather the Serial Numbers of the Printers in a way ... – WYSIWYG Apr 17 '14 at 05:03
0

Quite late to the party, but...

This should work at least for HP Office Jet (tested with HP Office Jet 4500). I don't have access to any other models but I can imagine that it works for any network-managed (HP) printer.

@echo off
setlocal
for /f %%a in ('curl "http://192.168.0.000/index.htm?cat=info&page=printerInfo#" 2^>nul ^|findstr /rc:" *CN"') do set "SN=%%a"
echo Serialnumber is %SN%.

This depends on the printer to be manufactured in China (Serial number starts with CN...

The question explicitly asks for a cmd solution. With any language with proper HTML or REGEX support, there are surely better (safer) solutions (not depending on CN...).

Also, the curl command might be subject to improvement (first time I used it)

the relevant section in the HTML looks like:

                  <tr>
                     <td class="info">
                        
                        Product Serial Number
                     </td>
                     <td>
                        CN000A000A00AA
                     </td>
                  </tr>

I extracted the link to the info page from curl <printer-ip>, which gave me

<body onLoad="window.top.location.href='./index.htm?cat=info&page=printerInfo'">

(which surely can be used to get the correct page with different models)

(Note: curl is now available with WIN 10, so this probably won't have worked back in 2014 "out of the box")

Stephan
  • 53,940
  • 10
  • 58
  • 91