Solved

Utility to get printer serial number

Posted on 2013-05-16
13
5,081 Views
Last Modified: 2016-11-12
I'm looking for a VBScript or any other utility available to get the serial number of Lexmark printers.

I already have this little script that gives me other details of a specific printer
Dim objWMIService, objItem, colItems, strComputer

strComputer ="??????"
strprinter = InputBox("Enter Printer Name")
If strprinter = "" Then
   wscript.quit
End If
Printer = "%" & ucase(strprinter) & "%"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer where Name like '" & printer & "' and Local=TRUE",,48)

For Each objItem In colItems
WScript.Echo objItem.name & VbCr & _
"========================" & VbCr & _
"Availability: " & objItem.Availability & VbCr & _
"Description: " & objItem.Description & VbCr & _
"Printer: " & objItem.DeviceID & VbCr & _
"Driver Name: " & objItem.DriverName & VbCr & _
"Port Name: " & objItem.PortName & VbCr & _
"Printer State: " & objItem.PrinterState & VbCr & _
"Printer Status: " & objItem.PrinterStatus & VbCr & _
"PrintJobDataType: " & objItem.PrintJobDataType & VbCr & _
"Print Processor: " & objItem.PrintProcessor & VbCr & _
"Spool Enabled: " & objItem.SpoolEnabled & VbCr & _
"Separator File: " & objItem.SeparatorFile & VbCr & _
"Queued: " & objItem.Queued & VbCr & _
"Status: " & objItem.Status & VbCr & _
"StatusInfo: " & objItem.StatusInfo & VbCr & _
"Published: " & objItem.Published & VbCr & _
"Shared: " & objItem.Shared & VbCr & _
"ShareName: " & objItem.ShareName & VbCr & _
"Direct: " & objItem.Direct & VbCr & _
"Location: " & objItem.Location & VbCr & _
"Priority: " & objItem.Priority & VbCr & _
"Work Offline: " & objItem.WorkOffline & VbCr & _
"Horizontal Res: " & objItem.HorizontalResolution & VbCr & _
"Vertical Res: " & objItem.VerticalResolution & VbCr & _
""
Next

WScript.Quit
0
Comment
Question by:Bianchi928
  • 4
  • 4
  • 2
  • +3
13 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39173059
I doubt if something like that is available.
0
 
LVL 1

Expert Comment

by:TXSolution79
ID: 39173094
If the printer has http web interface utility start their.
0
 

Author Comment

by:Bianchi928
ID: 39173119
Yes it does have...But how do I extract this info. I don't want to be going like http://10.??.??.?? for each single printer.
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39173148
I said I doubted if the serial number is available because there's no need for the OS to know about it. That's different from the other information you've gathered which concerns the printer's functionality or its state which the OS does need to know about.
0
 
LVL 7

Expert Comment

by:eerwalters
ID: 39173182
3 easier options than looking at each one manually

       1- Write your own SNMP utility to grab the data

       2- Use MarkVision Professional or Enterprise if you have a total LexMark shop.  You can export the scan results from that utility
           http://www1.lexmark.com/en_CA/software/markvision

       3- Use HP WebJetAdmin if you have a mixture of HP and LexMark.  Just realize that the serial # info gathered for the LexMark printers will vary depending on Make/Model.  You can export the results from this utility too.
          http://h20331.www2.hp.com/hpsub/cache/332262-0-0-225-121.html?jumpid=ex_r2845_go/webjetadmin/gc121306
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 39173427
What kind(s) of printers are they?  I did a fairly involved BAT script a while back to collect data from printers via SNMP, maybe that could be adapted.  Check out:

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24909017.html

~bp
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Bianchi928
ID: 39173441
Most of the printers are Lexmark T650n.

I've have a look at your link and come back to you

Thanks
Cheers
0
 

Author Comment

by:Bianchi928
ID: 39173489
hp,

I had a look at the link..There are so many examples.   which one you reckon I should use to run a test on

Thanks
Cheers
0
 
LVL 51

Accepted Solution

by:
Bill Prew earned 300 total points
ID: 39173561
Let's try a little test.  Here's a BAT script to run as a test that will try and get just the serial number.  Save it as a bat and edit the IP line to be the printer IP.

You will also need the attached utility file in the folder you run the BAT from.  Download it and rename to an EXE file.

@echo off
setlocal EnableDelayedExpansion
setlocal EnableExtensions

set IP=1.2.3.4

REM Get Serial
call :DoSnmpGet "%IP%" ".1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.3.0" "Serial"
REM If no serial found, try the XEROX MIB to see if it responds
if "!Serial!"=="N/A" (
  call :DoSnmpGet "%IP%" ".1.3.6.1.2.1.43.5.1.1.17.1" "Serial"
  REM If no serial found, try the RICOH MIB to see if it responds
  if "!Serial!"=="N/A" (
    call :DoSnmpGet "%IP%" ".1.3.6.1.4.1.367.3.2.1.2.1.4.0" "Serial"
    if NOT "!Serial!"=="N/A" (
      for /F "tokens=1 delims=," %%z in (!Serial!) do set Serial=%%z
      set Serial=!Serial:"=!
    )
  ) else (
    for /F "tokens=1 delims=," %%z in (!Serial!) do set Serial=%%z
    set Serial=!Serial:"=!
  )
)

echo Serial=%Serial%

exit /b

:DoSnmpGet
  REM Use SNMPGET to fetch value for IP and MIB passed in, return in variable passed in
  set %~3=N/A
  for /F "tokens=1-3*" %%t in ('snmpget -O T -v 1 -c public %~1 %~2 2^>nul^|find "="') do (
    set SnmpgetResult=%%w
    if "%%v"=="Hex-STRING:" (
      set SnmpgetResult=!SnmpgetResult: =!
      for /F "tokens=2 delims=[.]" %%z in ("!SnmpgetResult!") do set SnmpgetResult=%%z
    )
    set %~3=!SnmpgetResult!
  )
  exit /b

Open in new window

~bp
snmpget.txt
1
 

Author Closing Comment

by:Bianchi928
ID: 39173625
Works fine. Exactly what I wanted . Points are yours.
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 39173636
Thanks, glad that hekped.

~bp
0
 

Expert Comment

by:Muhammad Basir
ID: 41875892
hi Bill Prew
may i get the exe file for windows 64 bit  ?

Thanks in advance
Basir
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 41884945
I didn't create that utility, but a link to the site is below, take a look there for current versions and support info.

~bp
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now