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.


Printer Controller

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

Broadcasting Printer Port Change

Keywords: 	  Broadcasting Printer Port Change


I am trying to change the printer port on the fly, say from LPT1: to \\server\queue, but none of the DllCall examples work, I've tried DMC=27 and WININICHG=26 and the SendMessageA DllCall examples, but it doesn't work, any ideas....?

changing the default printer is easy, but I can't get the port changes to stick...


It's actually pretty simple using the Printer Extender after all...
; Print control extender

; current printer
prnt="HP LaserJet 4 on HO1244LN"

; port we want to change it to.

; name of print driver, (i.e. 'HP LaserJet 4')
prtdrv=RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Control\Print\Printers\%prnt%[Printer Driver]")

; print processor, (i.e. 'Winprint')
prtprc=RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Control\Print\Printers\%prnt%[Print Processor]")

; is it the default printer?
defprt = pGetDefPrtInf(1)

; print driver file, (i.e. 'HPPCL5MS')
hpdrv=StrUpper(RegQueryValue(@REGMACHINE,"System\CurrentControlSet\control\Print\Environments\Windows 4.0\Drivers\%prtdrv%[Driver]"))

; delete printer first.

; Presto, add printer back with new port.
pAddPrinter( "", prnt, newport, prtdrv, prtprc)

; if printer was the default, then we need to set it back.
If defprt == prnt Then pSetDefPrtEx( prnt, hpdrv, newport)

Article ID:   W14435
Filename:   Broadcasting Printer Port Change.txt
File Created: 2017:07:28:13:58:37
Last Updated: 2001:03:01:15:38:04