Page 1 of 1 1
Topic Options
#129041 - 2004-11-05 05:17 PM Error Codes for SetDefaultPrinter
andor Offline
Lurker

Registered: 2004-11-05
Posts: 3
I am using the SetDefaultPrinter command to set a default printer. Most of the time it works perfectly but about once every two weeks it is failing with error code 2. Where can I find out what a return code of 2 means or why this command may be failing during login?

Here is my code:

$ReturnCode = SetDefaultPrinter ("Tribeca PCL")
If $ReturnCode = 0
? "Set default printer to Tribeca PCL"
$RC = LogEvent( 0 , 5001 , "Set default printer to Tribeca PCL" , "", "DanPrinterScript" )
Else
? "Failed to set default printer to Tribeca PCL"
$RC = LogEvent( 0 , 5002 , "FAILED to set default printer to Tribeca PCL (error code: " + $ReturnCode +")" , "", "DanPrinterScript" )
Endif
EndIf

Here is the output in the event log:

FAILED to set default printer to Tribeca PCL (error code: 2).

Thanks for the help!

Top
#129042 - 2004-11-05 05:18 PM Re: Error Codes for SetDefaultPrinter
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Have you tried @SERROR? See manual.
Top
#129043 - 2004-11-05 05:44 PM Re: Error Codes for SetDefaultPrinter
andor Offline
Lurker

Registered: 2004-11-05
Posts: 3
Fantastic! I added @serror to the code. The next time it fails I will have that error code text. I will post what the error was when I get it again. Thanks!
Top
#129044 - 2004-11-05 07:58 PM Re: Error Codes for SetDefaultPrinter
andor Offline
Lurker

Registered: 2004-11-05
Posts: 3
I found the error:

FAILED to set default printer to Tribeca PCL (error code: 2, The system cannot find the file specified.)

I am using the \\server\PRINTERNAME and it works most of the time so I am not sure why this command is not working. Especially beacsue it is setting the default printer to a locally attached printer in this case so there aren't any network issues.

Top
#191313 - 2008-12-18 10:43 PM Re: Error Codes for SetDefaultPrinter [Re: andor]
Mr.Kevin Offline
Fresh Scripter

Registered: 2003-03-26
Posts: 9
Loc: Altamonte Springs, FL
I had this issue, my share name is different them my printer name. When i changed the name to my printer name it worked.

example = SetDefaultPrinter ("\\printerserver\hplj4")
that did not work

under the general tab of my printer properties the printer name was "HP Lasterjet4 - 2nd Floor"

When I changed my code to SetDefaultPrinter ("\\printerserver\HP Lasterjet4 - 2nd Floor") it worked.

Hope this helps someone.

Top
#191319 - 2008-12-19 12:32 AM Re: Error Codes for SetDefaultPrinter [Re: Mr.Kevin]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
This is by design.

If you want to use the share name you can use the UDF SetAsDefaultPrinter - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=187517#Post187517
_________________________
(... better days ahead)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 641 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.08 seconds in which 0.056 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org