WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Printer Controller

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

pGetDefPrtInf Bug


Question:

I stumbled onto a bizarre problem (possibly a bug) when creating a printer inventory script. One of the steps required of the inventory is determining the default printer. To accomplish this, I use the pGetDefPrtInf command and test each of the printer names on the PC against the name returned by the function. Another important aspect of the inventory is to figure out which printers are local and which are networked based. To determine this, I use the pGetPrtInfo command (passing the '1' request) and if the server is blank (i.e. "") then I can assume it's a local printer.

What I believe to be the bug occurs when using the pGetDefPrtInf command before using the pGetPrtInfo command. Review the following code and comments (which was whipped up for demonstration):

; Initialize extender and get printer list
AddExtender("WWPRT34i.DLL")
printers = pGetPrtList(0)

; Offer list to user -- choose a local printer
chosen = AskItemList("Printers", printers, @tab, @sorted, @single)

; Display the server name.
; If you chose a local printer, the message box should be blank
srvname = pGetPrtInfo(chosen, 1)
Message ("Before",srvname)

; Now grab the default printer info
defprt = pGetDefPrtInf(1)

; Excute the same command as above.
; This time, the server name will be populated -- this is the bug.
srvname = pGetPrtInfo(chosen, 1)
Message ("After",srvname)

Exit 
As mentioned in the comments, after the pGetDefPrtInf command is called, the server name for local printers gets populated. So am I going insane? Or is this a bug? (perhaps both?)

Debug output is as follows:

************************************************************

*** Debug Initialized ***

==============================
Wed 6/23/2004 4:29:15 PM
WinBatch 32 2004A
WIL DLL 4.4add
\\hscinstall\scripts\code\msm Packages\PrinterInv\temp.exe
Windows platform: NT, version: 5.0, build: 2195 (Service Pack 4)
==============================

----- Extender loaded: \\hscinstall\scripts\code\msm Packages\PrinterInv\WWPRT34i.DLL (file version: 39004,0,0,0)

AddExtender("WWPRT34i.DLL")
(60) VALUE=> 1

printers = pGetPrtList(0)
(70) VALUE=> "Microsoft Office Document Image Writer HP LaserJet 5 Acrobat PDFWriter Acrobat Distiller \\hscsprint1\STHMT03 \\hscsprint3\STHMT11 \\hscsprint3\STHMT13"

chosen = AskItemList("Printers", printers, @tab, @sorted, @single)
(5658) VALUE=> "HP LaserJet 5"

srvname = pGetPrtInfo(chosen, 1)
(5668) VALUE=> ""

Message ("Before",srvname)
(8152) VALUE=> 1

defprt = pGetDefPrtInf(1)
(8152) VALUE=> "HP LaserJet 5"

srvname = pGetPrtInfo(chosen, 1)
(8162) VALUE=> "HP LaserJet 5"

Message ("After",srvname)
(9634) VALUE=> 1

Exit
(9634) VALUE=> 0

--- Normal termination ---

;;;END OF JOB;;; 
As you can see from the debug file posted above, the first time I call the function against the local printer, I get a blank string. The second time I call the same function (after calling pGetDefPrtInf) I get a value and NOT a blank string.

Answer:

Developers have fixed this bug and released a new version of the Printer Extender.

Note: This is a 44I version of the extender, requiring you to update to the current version of WinBatch, anc to edit the AddExtender line in your script.


Article ID:   W16354
File Created: 2005:02:18:12:19:58
Last Updated: 2005:02:18:12:19:58