#148200 - 2005-09-21 03:08 PM
SetDefaultPrinter() - documentation error
|
reedmikel
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
|
|
|
|
#148203 - 2005-09-21 04:01 PM
Re: SetDefaultPrinter() - documentation error
|
reedmikel
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
|
|
|
|
#148206 - 2005-09-21 04:12 PM
Re: SetDefaultPrinter() - documentation error
|
reedmikel
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
|
|
|
|
#148208 - 2005-09-21 04:37 PM
Re: SetDefaultPrinter() - documentation error
|
reedmikel
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
|
|
|
|
#148211 - 2005-09-21 05:04 PM
Re: SetDefaultPrinter() - documentation error
|
reedmikel
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
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
|
|
|
|
#148214 - 2005-09-21 06:38 PM
Re: SetDefaultPrinter() - documentation error
|
reedmikel
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
|
|
|
|
#148216 - 2005-09-21 11:11 PM
Re: SetDefaultPrinter() - documentation error
|
iffy
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.
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 242 anonymous users online.
|
|
|