Page 1 of 3 123>
Topic Options
#148200 - 2005-09-21 03:08 PM SetDefaultPrinter() - documentation error
reedmikel Offline
Fresh Scripter
**

Registered: 2005-09-21
Posts: 27
I've spent over 10 hours trying to get a logon script that sets a workstation's default printer to function properly The workstations are all XP-SP2 machines connected to a Windows 2000 Advanced server. The printer is a server-based printer shared as \\servername\sharename. At first I tried using KIX's SHELL command to execute a rundll32 printui.dll,PrintUIEntry /y /in /n\\servername\sharename command. Notice the command was to add the network printer AND set it to be the default printer. But it would fail, reporting it could not find or connect to printer. After hours of playing around with printui.dll, I got the bright idea to check KiXtart, which my script was written in, and saw the AddPrinterConnection() and SetDefaultPrinter() commands Now the AddPrinterConnection("\\servername\sharename") command worked just as documented. BUT the SetDefaultPrinter("\\servername\sharename") would always return an error code 2(I think 2 means: not found). More time spent testing variations of my script, but still could not set the default printer...

Finally I searched this forum, and saw quite a few folks with similiar problems. Overwhelmingly the advice was to use the same name for sharename as for printer name. Well, us older legacy appl folks do not like to do that, preferring to keep sharenames to 8 or less characters, no spaces etc. Printer names, on the other hand, are supposed to be verbose and clearly identify the printer to the user. So in a last ditch effort at 12:30am last night(morning), I tried SetDefaultPrinter("\\servername\printer name"). Amazing - it worked

So the reason for my post is twofold: 1) save others hours of wasted time 2) let the author(s) know that their documentation has been incorrect all these years for the SetDefaultPrinter() command

Below is the description from kix2001.doc - notice that it says to use "sharename". WRONG - please update it to say PRINTER NAME. And you might as well add a special note: (unlike AddPrinterConnection(), this command does NOT use the sharename, but the full name of printer).

String that specifies the fully qualified name of the printer to set as the default printer. Note that if the printer involved was connected to using AddPrinterConnection, you must include both the servername and the sharename...


Don;t get me wrong, I LOVE KiXtart! Just don't like spending endless hours tracking down documentation errors. OTOH, I should have known better as I am a programmer. Years ago I wrote FoxPro code that called low-level Windows APIs and I think I encountered a similiar problem. If I remember correctly, the underlying OS made a difference. I think Win9x needed the \\servername\sharename, whereas NT,2000,XP etc. needed \\servername\printername. I'm guessing KiXtart uses the same Windows APIs and that is the reason for this confusion. Perhaps the documentation may need to be even further enhanced to explain that the syntax for SetDefaultPrinter is OS-dependent. But I leave that testing to someone else

Thanks for such a great tool!

Top
#148201 - 2005-09-21 03:32 PM Re: SetDefaultPrinter() - documentation error
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yo yo.
we hear you.
we have been there too.
I bet everyone who has ever tried setDefaultPrinter()

but you saying it's the documentation, you are mocking wrong tree.
a clip from 4.50 kixtart2010.doc:
Code:

SETDEFAULTPRINTER

Action
Sets the default printer to which applications send print jobs.

Syntax
SETDEFAULTPRINTER ("printer name")

Parameters
Printer name
String that specifies the fully qualified name of the printer to set as the default printer.

Note that if the printer involved was connected to using AddPrinterConnection, you must include both the servername and the sharename.

Returns

0 Default printer set
Error code Function failed

Example
If AddPrinterConnection ("\\vleerbeer\hp laserjet 4") = 0
? "Added printer connection...."
If SetDefaultPrinter ("\\vleerbeer\hp laserjet 4") = 0
? "Set default printer to HP LaserJet 4...."
Endif
Endif



the note line is way of though:
Quote:

Note that if the printer involved was connected to using AddPrinterConnection, you must include both the servername and the sharename.




and what comes to OS specific.
it shouldn't be.
these should all work from win95 and winNT onwards.
_________________________
!

download KiXnet

Top
#148202 - 2005-09-21 03:57 PM Re: SetDefaultPrinter() - documentation error
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I agree with Jooel. The manual is correct. Your interpertation is flawed.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148203 - 2005-09-21 04:01 PM Re: SetDefaultPrinter() - documentation error
reedmikel Offline
Fresh Scripter
**

Registered: 2005-09-21
Posts: 27
Actually, you just confirmed my original post The documentation for SetPrinterDefault(), where it states "Note that if the printer involved was connected to using AddPrinterConnection(), you must include both the servername and the sharename" is absolutely, totally WRONG. The SHARENAME should NOT be passed as part of the "printer name" parameter! If you really read the documentation, and you are trying to set the default printer to a printer that you previously connected to with AddPrinterConnection(), specifying the sharename DOES NOT WORK...

Believe me, I just spent countless hours verifying this.

On the otherhand, the documentation is correct IF you are not specifying a network shared printer. So some of you will have had no problem with this command... Or, if you were lucky enough to NOT read the sentence "Note...", then you will have luckily stumbled into the correct syntax

Top
#148204 - 2005-09-21 04:04 PM Re: SetDefaultPrinter() - documentation error
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Once again, your interpretaion is flawed. We have to assume that Ruud attempted to bring light to the fact that AddPrinterConnection() uses the ShareName and SetDefaultPrinter() uses the printer name.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148205 - 2005-09-21 04:07 PM Re: SetDefaultPrinter() - documentation error
reedmikel Offline
Fresh Scripter
**

Registered: 2005-09-21
Posts: 27
Wow, how can one misunderstand the documentation's sentence under SetDefaultPrinter() that clearly states "Note that if the printer involved was connected to using AddPrinterConnection, you must include both the servername and the sharename" ? I did add the printer using a AddPrinterConnection("\\servername\sharename") command. So I followed the instructions that I bolded above. How do you interpret sharename to mean printer name?

Maybe I followed the instructions too literally? But isn't that what programming is all about?

Top
#148206 - 2005-09-21 04:12 PM Re: SetDefaultPrinter() - documentation error
reedmikel Offline
Fresh Scripter
**

Registered: 2005-09-21
Posts: 27
We NOW know how SetPrinterDefault() works. That is not the only issue. I am trying to point out, what I thought was an obvious error in the documentation. Why do you both, in your heads, automatically translate the documentation from saying "Note that if the printer involved was connected to using AddPrinterConnection, you must include both the servername and the sharename" to "Note that if the printer involved was connected to using AddPrinterConnection, you must include both the servername and the PRINTER NAME"?

I guess we speak/read different languages

Top
#148207 - 2005-09-21 04:13 PM Re: SetDefaultPrinter() - documentation error
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You are taking that one sentence out of context! Taken with the example before it should make the intent very clear. Stop blaming Ruud for your ineptitude.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148208 - 2005-09-21 04:37 PM Re: SetDefaultPrinter() - documentation error
reedmikel Offline
Fresh Scripter
**

Registered: 2005-09-21
Posts: 27
Wow, I did not know that people were so sensitive on this forum when a fellow programmer(over 20 years in assembler, C, FoxPro...) points out an error in the documentation.

Maybe I should explain more clearly how I interpreted the documentation:

The SetDefaultPrinter("printer name") documentation states:
"Printer name: String that specifies the fully qualified name of the printer to set as the default printer. Note that if the printer involved was connected to using AddPrinterConnection, you must include both the servername and the sharename"

I assumed that the first sentence, where it does state "fully qualified name of printer", to only apply to printers that were not added with AddPrinterConnection(). I assumed that because of the second sentence "Note that if the printer involved was connected to using AddPrinterConnection, you must include both the servername and the sharename"

If you go look at the syntax/documentation for AddPrinterConnection("printer name"), it states "Printer name: The (share)name of the printer to which to connect"

I have not tried it, but now I wonder if AddPrinterConnection("printer name of a shared printer") works? As opposed to AddPrinterConnection("share name of a shared printer") - which I have used successfully...

So when is a share name a printer name and vice versa? I think you are faulting me for reading a technical document too technically:)

Perhaps you know KiXtart so well, maybe too well, to be a fair judge of this matter? I know that sometimes I don't at first agree with criticisms of software tools that I have written. Why? Because I just happen to KNOW all the oddities and anomalies of how my own product works...

Lastly, maybe you should read the forum rules on etiquette! You don't need to embarass yourself by making such child-like comments as "ineptitude". That's just not a mature way to discuss things...

Top
#148209 - 2005-09-21 04:50 PM Re: SetDefaultPrinter() - documentation error
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK

Quote:


Why do you both, in your heads, automatically translate





I know that someone might not be able to read the simple manual.
or someone has hard time reading my simple english.

but how the heck that sorta person could be able to read my mind?
come on. leave my head out of this and start using your own.
_________________________
!

download KiXnet

Top
#148210 - 2005-09-21 04:53 PM Re: SetDefaultPrinter() - documentation error
reedmikel Offline
Fresh Scripter
**

Registered: 2005-09-21
Posts: 27
Wow - you are angry. Come back when things have settled down for you...

Peace

Top
#148211 - 2005-09-21 05:04 PM Re: SetDefaultPrinter() - documentation error
reedmikel Offline
Fresh Scripter
**

Registered: 2005-09-21
Posts: 27
And you're a "moderator" at this forum? I hope we don't see you moderating anytime soon at the United Nations
Top
#148212 - 2005-09-21 05:18 PM Re: SetDefaultPrinter() - documentation error
reedmikel Offline
Fresh Scripter
**

Registered: 2005-09-21
Posts: 27
Oops, now I sense why you overreacted: You wrote the manual, didn't you?

I did not mean to hurt your feelings - the product is superb!!! All I was doing is pointing out inconsistencies/errors in the documentation.

Why don't you ignore my criticism(for the moment), and research the forums here and see how many times this confusion has occurred to other users? If I am the only person, then just forget my comments. But I seem to recall plenty of threads where users were always advised to make their printer's sharename the same as the actual printer name. That's what led me to the solution...

Maybe just a little refinement in the manual could put an end to the confusion that SOME of us have experienced. Isn't that why software and manuals have revisions? It's not about who's right, or who's wrong - the objective should be to make the manual and product work as well as possible for the vast majority of users. If 10% of users are confused because of the way something is, or is not, worded, why not revise it and make it clearer?

I rest my case and leave you to decide what is best in the interest of all

Top
#148213 - 2005-09-21 05:53 PM Re: SetDefaultPrinter() - documentation error
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
OK, I admit I went over the top a bit with my ineptitude comment but your arguement was sounding to me like the wife beater blaming her for angering him. For that, I apologize.

You are correct, that the manual could always be improved and to that end, I welcome you to post to the suggestions forum, some verbage you would like to see.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148214 - 2005-09-21 06:38 PM Re: SetDefaultPrinter() - documentation error
reedmikel Offline
Fresh Scripter
**

Registered: 2005-09-21
Posts: 27
I think sometimes people read my emails the wrong way because of the way I capatilize and bold things. I do that only to make a point, as many times we all gloss over things too fast and miss a key point. I am not yelling when I use such techniques, really

If I were to attempt some revisions, they'd be something like:

AddPrinterConnection:
Parameters:
Printer name: string that specifies the fully qualified(UNC) name of the shared printer, in the format "\\servername\sharename"

Note that, unlike the SetDefaultPrinter("Printer name") command, the "Printer name" parameter used in AddPrinterConnection is the shared name of the printer, not the actual name of the printer.


SetDefaultPrinter:
Parameters:
Printer name: string that specifies the actual name of the printer, in a fully qualified(UNC) format such as "\\servername\printer's name".

Note that, unlike the AddPrinterConnection("Printer name") command, the "Printer name" parameter used in SetDefaultPrinter is the name of the printer, not the shared name of the printer. The printer's actual name is displayed on the General tab of the Properties for that printer.

------ end of suggestion -----------------

Do you know if AddPrinterConnection("\\servername\Name of Printer") works? I used "\\servername\sharename" and that sysntax worked fine for me. Should I switch it to the former syntax?

Thanks for reviewing this!

Top
#148215 - 2005-09-21 07:50 PM Re: SetDefaultPrinter() - documentation error
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Sjees some heavy posting going on here Hope things calmed down again

Like Les said if you post the suggestions to do a change to the manual in the suggestions forum good chance Ruud (the developer of kixtart and author of the manual) will see it in a few days from now and who knows implement it into the manual. He's currently working on KiXtart 4.51 (beta 2 is out).
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#148216 - 2005-09-21 11:11 PM Re: SetDefaultPrinter() - documentation error
iffy Offline
Starting to like KiXtart

Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
Well, to start a flame war... Les seems to have that "way" with just about any comment he makes. Clearly he's knowledgeble but his approach in answering questions is by implying that the one asking is dumb as an ass and should not be allowed to touch a keyboard. Maybe an extended leave to work out his problems is an idea but I wouldn't want to assume to know it all. Anyway, imho Les puts the other moderators on this board to shame with his attitude.

/me bends over.. ok kick me

Top
#148217 - 2005-09-22 12:25 AM Re: SetDefaultPrinter() - documentation error
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Quote:

imho Les puts the other moderators on this board to shame with his attitude




The way this is worded would imply that the other moderators should aspire to be more Les-like as we are the one's who are shamed.

Top
#148218 - 2005-09-22 12:25 AM Re: SetDefaultPrinter() - documentation error
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well...
iffy, I think blaming les here is kinda over the edge as reedmikel just failed to read the lines that were given to him.

I know, les has a way of saying things that might sound little hursh but again, that was no place for reedmikel to start shooting around saying that neither les nor I have functioning brains or that he can read them like pageless open book.

now, like I said in my very first post in this thread, "we all" have experienced this caveat of setdefaultprinter() "oddity"
and as far as I remember, the manual has been fixed already once on this section.
and changing this note line is now under consideration.

anyways, shouting about it blindly won't bring change, only headache.
_________________________
!

download KiXnet

Top
#148219 - 2005-09-22 12:37 AM Re: SetDefaultPrinter() - documentation error
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
chris, when I was mod, I strived for that perfection too
_________________________
!

download KiXnet

Top
Page 1 of 3 123>


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

Who's Online
0 registered and 2141 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.533 seconds in which 0.059 seconds were spent on a total of 12 queries. Zlib compression enabled.

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