#42117 - 2003-06-27 12:28 AM
Problem With SetDefaultPrinter
|
Justin Emlay
Fresh Scripter
Registered: 2002-05-24
Posts: 26
|
Here is my entire test script:
AddPrinterConnection ("\\FILE\SALES_R1045") AddPrinterConnection ("\\FILE\SALES_FAX") SetDefaultPrinter ("SALES_R1045")
Now this should add two printers and set one of them as default. WindowsXP.
The problem is the default isn't setting itself and I get a return code of "2". Here's the odd part. If I add: SetDefaultPrinter ("\\FILE\SALES_R1045")
right above my initial SetDefaultPrinter and run the script then it still doesn't work. Run the script a second and it works!
Remove that line and it doesn't matter how many times I run the script it wont set the printer as default.
Ideas?
|
Top
|
|
|
|
#42118 - 2003-06-27 12:36 AM
Re: Problem With SetDefaultPrinter
|
Justin Emlay
Fresh Scripter
Registered: 2002-05-24
Posts: 26
|
This is even odder. Since it had to run twice I wanted to see what would happen if I plugged in that extra line twice:
AddPrinterConnection ("\\FILE\SALES_R1045") AddPrinterConnection ("\\FILE\SALES_FAX") SetDefaultPrinter ("\\FILE\SALES_R1045") SetDefaultPrinter ("SALES_R1045") SetDefaultPrinter ("\\FILE\SALES_R1045")
This sets the printer as default by only running the script once however there is a very bad after effect. When you go into printers the orignal printer is marked as default AND the new printer is marked as default. While other programs see the new printer as default (first selected) if you try to make another printer default (manualy) it fails.
|
Top
|
|
|
|
#42120 - 2003-06-27 06:55 PM
Re: Problem With SetDefaultPrinter
|
Justin Emlay
Fresh Scripter
Registered: 2002-05-24
Posts: 26
|
I've used that bit of code to determine what was wrong. Nothing gets displayed. As well the printer still is not set as default.
I've done this while booting the machine as well.
I am the administrator of my machine and the entire network. The printers get add just fine.
|
Top
|
|
|
|
#42122 - 2003-06-27 07:26 PM
Re: Problem With SetDefaultPrinter
|
Justin Emlay
Fresh Scripter
Registered: 2002-05-24
Posts: 26
|
Yup, and to prove it and to test W2K I loaded a W2K station and logged on with that. Worked just fine.
So W2K works and XP doesn't.
|
Top
|
|
|
|
#42123 - 2003-06-27 07:47 PM
Re: Problem With SetDefaultPrinter
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Justin,
Have you had a look at -
KiXtart FAQ & How to's
And specifically - Default Printer Configuration
??
This has the SETDEFAULTPRINTER used within and we have several XP Workstations that works just fine.
Can I ask a silly question?
With the example you provided -
code:
AddPrinterConnection ("\\FILE\SALES_R1045") AddPrinterConnection ("\\FILE\SALES_FAX") SetDefaultPrinter ("\\FILE\SALES_R1045") SetDefaultPrinter ("SALES_R1045") SetDefaultPrinter ("\\FILE\SALES_R1045")
Why are you repeating the SetDefaultPrinter ?
Thanks,
Kent
|
Top
|
|
|
|
#42125 - 2003-06-27 08:34 PM
Re: Problem With SetDefaultPrinter
|
Justin Emlay
Fresh Scripter
Registered: 2002-05-24
Posts: 26
|
"Why are you repeating the SetDefaultPrinter ?" That was explained in the first two posts. Read them together and you have your answer.
"Are you sure the script is even running on XP?" As I said above the printers get added just fine. I would have to say then the script is firing.
|
Top
|
|
|
|
#42127 - 2003-06-27 09:15 PM
Re: Problem With SetDefaultPrinter
|
Justin Emlay
Fresh Scripter
Registered: 2002-05-24
Posts: 26
|
Clarification:
Windows 2000 - Add Printers OK Windows 2000 - Change Default OK
Windows XP - Add Printers OK Windows XP - Change Default BAD
I reloaded the machine with W2K on it with WinXP and ran the script localy (no network setup). It worked fine. So either there is a problem running it remotly or there is a problem with my network setup conflicting with KiXtart.
|
Top
|
|
|
|
#42129 - 2003-06-27 10:33 PM
Re: Problem With SetDefaultPrinter
|
Justin Emlay
Fresh Scripter
Registered: 2002-05-24
Posts: 26
|
ok, no offense to you but you need to re-read this post. I've already gone over that and I have explained twice why it's doubled up. Either way those extra lines are no longer in the the script, it was a TEST.
What I do see when I run the script as such: AddPrinterConnection ("\\FILE\SALES_R1045") AddPrinterConnection ("\\FILE\SALES_FAX") SetDefaultPrinter ("SALES_R1045")
is "002". When I add "? 'Error '+@ERROR+' - '+@SERROR", I get nothing else. Keep in mind it DOES add the printers.
|
Top
|
|
|
|
#42131 - 2003-06-27 10:40 PM
Re: Problem With SetDefaultPrinter
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Wouldn't it be -
SetDefaultPrinter ("\\FILE\SALES_R1045")
??
Thanks!
Kent
|
Top
|
|
|
|
#42134 - 2003-06-27 11:15 PM
Re: Problem With SetDefaultPrinter
|
Justin Emlay
Fresh Scripter
Registered: 2002-05-24
Posts: 26
|
No you are wrong, the following is incorrect:
SetDefaultPrinter ("\\FILE\SALES_R1045")
The following is my script: AddPrinterConnection ("\\FILE\SALES_R1045") AddPrinterConnection ("\\FILE\SALES_FAX") SetDefaultPrinter ("SALES_R1045")
This works in W2K. So my SetDefaultPrinter statement is correct. Yours is wrong. It doesn't work in WinXP. HOWEVER the two lines above it does work. So my script is working.
You tell me to change the line but it works in W2K. You tell me my script doesn't work in general but it is adding the printers. As for that line of code once I see the "002" the window flashes by so quick and goes away maybe I'm just not seeing the return on it.
I guess this problem is above you. Never mind then. Thanks for your time.
|
Top
|
|
|
|
#42136 - 2003-06-27 11:42 PM
Re: Problem With SetDefaultPrinter
|
Justin Emlay
Fresh Scripter
Registered: 2002-05-24
Posts: 26
|
Ok, lets take it from here then.
I did as such and again I got 002. Only on seperate lines with the verbage you specified. The 2 meaning can not find file specified.
So now answer this. If SetDefaultPrinter can not find file specified then how can SETDEFAULTPRINTER find it and install it.
Also when I move to a W2K machine I get "000" and it works fine.
Also, I HAVE tried to just use "SetDefaultPrinter ("\\FILE\SALES_R1045")" and that doesn't work either. I get a "000" but it doesn't actualy set the printer as default. Also that doesn't explain how this: "SetDefaultPrinter ("SALES_R1045")" does work just fine for W2K.
Are you tring to tell me that W2K requires it one way and WinXP requires it the other way?
Cut and paste: Error 0 - The operation completed successfully. Error 0 - The operation completed successfully. Error 2 - The system cannot find the file specified. Press any key to continue
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 896 anonymous users online.
|
|
|