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.

Error 510 pSetPrtInfo


Question:

The following script was able to find the target printer and report the current port of it. However, the pSetPrtInfo command failed to change the port of the target printer. It returned an error of 510 Error Setting Printer Information.

What is wrong in the script ?

Background info:

OS = W2K
Winbatch Compiler = 2002G
Extender=Printer Extender
Task = Using pSetPrtInfo()to change the port.
Script:
AddExtender("WWPRT34i.DLL")
CurPrinterLst=pGetPrtList( 0)
Targetprinter="HP LaserJet 5Si"
PrnExist=ItemLocate (CurPrinterLst, Targetprinter, @tab)
tPrtPort=pGetPrtInfo( Targetprinter, 4)
CPPResult=pSetPrtInfo(Targetprinter, 4, "COM2")
Exit

Answer:

What extended error information does this return? Try using pGetErrorCode and pGetErrorMsg to get the extended error.
ErrorMode(@OFF)
CPPResult=pSetPrtInfo(Targetprinter, 4, "COM2")
ErrorMode(@CANCEL)
If CPPResult == 0
	errcode = pGetErrorCode()
	errmsg = pGetErrorMsg()
	Message(errcode, errmsg)
	exit
Endif

User Reply:

I received the 1796 error code "The specified port is unknown"

Answer:

Its doesn't seem to like, the port name your passing it. The error 1796 The specified port is unknown (ERROR_UNKNOWN_PORT) is a Windows error. Maybe set the printer up how you like it manually, then use pGetPrtInfo to read the port value and see what it returns.

User Reply:

I've found cause of the problem. I specified the port value wrong. It should have the colon at the end as part of the port value.

The line should read:

CPPResult=pSetPrtInfo(Targetprinter, 4, "COM2:")

Article ID:   W16353
File Created: 2017:07:28:13:58:37
Last Updated: 2005:02:18:12:19:58