Page 2 of 2 <12
Topic Options
#204776 - 2012-04-19 05:51 PM Re: SetDefaultPrinter bug [Re: Les]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4557
Loc: USA
Well... sad to say, I had the gold in my hand, and didn't know it... \:\(

 Quote:

and aside from capitalization looks exactly the same with kix or using the GUI for me


Les, I think what he has works because Kix is so forgiving, but you are right, that does need to be in an if or at the very least done like this: $RC=addprinterconnection("\\Server\Share")

Top
#204781 - 2012-04-19 07:41 PM Re: SetDefaultPrinter bug [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Does this work?

 Code:
$ServerName = LCase(@LServer)
SetDefaultPrinter ($ServerName + "\ICT Colour"

Top
#204795 - 2012-04-19 08:59 PM Re: SetDefaultPrinter bug [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

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

is the addprinterconnection also with lower case?
does it work if you use @lserver with addprinterconnection AND setdefaultprinter?

I think what is going on in here is that the program cares about case even though windows doesn't.
windows still stores the case in the default printer info and thus, if the case for the added printer and default printer are different, the program gets confused.

continuing on this logic, vbscript then only works as long as the printer is also added lowercase. if you add it with kix and have capitals in it, then it should fail. or, as Shane suggested, using only lowercase default printer.
if the printername (and the servername) contain uppercase characters in both places:
a) HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices
b) HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows,Device-value

and the program still doesn't work right, then the program only accepts lowercase servername, which is odd and shall be an issue with the program itself.
if it works, then it's just matter of the program caring too much in windows standards but I might not call it a bug in that cause. maybe a odd feature instead.
_________________________
!

download KiXnet

Top
#204801 - 2012-04-19 11:31 PM Re: SetDefaultPrinter bug [Re: Lonkero]
Robdutoit Offline
Hey THIS is FUN
***

Registered: 2012-03-27
Posts: 363
Loc: London, England
Sorry, I did not copy the coding across correctly, I meant to delete the = 0 part of the coding. Yes, you are quite right that I should have the if endif scenario. But that does not affect the outcome here. Whether the if is used or not, the setdefaultprinter only works if I put in the correct case of the name of the server. But thanks for pointing that out Les

Oh Allen, the irony - yes you had the gold in your hands. I hate it when that happens to me, when its been in front of my eyes all along and I missed it. Been there many times.

To ShaneEp, your suggestion would only work if all the servers names were in lower case, which they may not be. The more relevant question is why the case sensitivity is an issue for setdefaultprinter when its not an issue for the vbs coding. The vbs coding does not care about the case sensitivity.

To Lonkero, the issue may only affect this specific program, in which case its not a major issue. But I can put in Server (CAPS) in the vbs code and it works. It only fails with setdefaultprinter macro. I have just checked the coding and at this specific client the addprinter is set using server not Server. So you may have something there, but your explanation does not explain why the VBS code does not care about the case sensitivity. I brought the CD of the program home with me. I will test out whether the setdefaultprinter function working properly depends on the case of the server name or on the case of the addprinter function and get back to you. But this below works

Set net = WScript.CreateObject("wscript.network")
net.SetDefaultPrinter "\\Server\ict colour"

I have no answer for why the capital S works in the vbs script, but it doesn't work in setdefaultprinter.

Worst thing about coding has always been the damn punctuation lol ! Gets me every time.

Top
#204802 - 2012-04-19 11:37 PM Re: SetDefaultPrinter bug [Re: Robdutoit]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
did you check the registry values?
if you input the "Server" in the vbs and go and see the registry and it's there in lower case, well, there is the answer.
vbs either lowercases it always, or checks the printer that is mapped and uses that case.
_________________________
!

download KiXnet

Top
#204807 - 2012-04-20 03:16 AM Re: SetDefaultPrinter bug [Re: Lonkero]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4557
Loc: USA
This is interesting...

 Code:
setdefaultprinter(lcase("\\Server\Brother HL-2270DW series"))

sets the registry to an all lowercase printer, and you have to refresh/F5 to see the default printer change in GUI.

 Code:
Dim $net
$net = CreateObject("wscript.network")
$net.SetDefaultPrinter(lcase("\\Server\Brother HL-2270DW series"))

sets the registry ignoring the lower case function and sets it to match the name in the GUI. The GUI automatically switches the default without having to refresh/F5.

Top
#204810 - 2012-04-20 04:53 AM Re: SetDefaultPrinter bug [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh, so vbs actually has a logic in there.
now, the question is, in windows world, what does it matter what case it is?
I almost want see what kinda code Ruud runs in the kix because I bet he has no case preserving logic in there.

I did find other programs that require case to be correct, like ICA or access.
but, the reason the case mattered was always something funky.

I found lot of comments that printernames are case-sensitive but, nothing from microsoft.

Ruud? some thoughts?
_________________________
!

download KiXnet

Top
#204838 - 2012-04-21 12:50 PM Re: SetDefaultPrinter bug [Re: Lonkero]
Robdutoit Offline
Hey THIS is FUN
***

Registered: 2012-03-27
Posts: 363
Loc: London, England
I can confirm Allen's experiment. If I put in catc for name of printer in the vbs coding, the registry will show it as CatC which is what I named the printer in this test. Thats why the VBS works, because it changes the case to whatever the actual case of the printer is.

To Lonkero, testing on my computer reveals that the program doesn't care whether the name is upper or lower case, it is only interested in matching the case identically. so if the printer name is CatC, then thats what I need to put in the setdefaultprint coding. so its not just the name of the server - in my clients case, the name of the printer just happened to be in the correct case by co-incidence, it was the server name that was in the wrong case.

With regards to whether setdefaultprinter should be modified to take this issue into account, I must leave to yourselves to decide. If I am the only person in over a decade that has an issue with setdefaultprinter, then I do not see the value in modifying the setdefaultprinter function.

I am quite happy to use the vbs coding so that I don't have to worry about case sensitivity. I did mention in an earlier post that Kixtart could consider deprecating setdefaultprinter in favour of the vbs coding. But thats up to you. Now if I could find the cause of my having to login twice every single time onto the Kixtart forum, I will be chuffed.

thanks for all the input. We got there eventually lol

Top
#204841 - 2012-04-21 02:07 PM Re: SetDefaultPrinter bug [Re: Robdutoit]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, nothing vbs can supersede something kix.

anyways, it doesn't take Ruud much effort to change the logic and I think he should do it. it won't break any fucntionality just improves it.

and thanks to Allen for checking the registry confirming where the problem actually lies.
_________________________
!

download KiXnet

Top
#204861 - 2012-04-21 07:18 PM Re: SetDefaultPrinter bug [Re: Lonkero]
Robdutoit Offline
Hey THIS is FUN
***

Registered: 2012-03-27
Posts: 363
Loc: London, England
When I say VBS, I am actually referring to the coding that was converted from VBS into Kixtart to be accurate. My concern is that its not necessary to create work (ie update setdefaultprinter) because one person in a decade had a problem with it. But if it only takes 5 minutes or so, then it might be a worthwhile update. Cheers Rob
Top
#205722 - 2012-09-10 08:11 PM Re: SetDefaultPrinter bug [Re: Robdutoit]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Well, I don't have the software mentioned, so I can't check with that, but I do see that there's a difference between the result of setting the default printer with VBS or KIX.

And I'll investigate that to see if I can align Kix with what Vbs (or actually: WScript) does.

Thanks for the report!

Ruud

Top
#205730 - 2012-09-11 05:22 PM Re: SetDefaultPrinter bug [Re: Ruud van Velsen]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Actually, I did some more research and found that KiXtart produces the exact same result as manually setting the default printer does. VBS/WSH for some reason produces a different result.

So, I expect the issue reported at the start of this thread also occurs if the printer is set manually.

As such, I will leave things as is in KiXtart.

Kind regards,

Ruud

Top
#205731 - 2012-09-11 11:13 PM Re: SetDefaultPrinter bug [Re: Ruud van Velsen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4557
Loc: USA
Maybe I don't understand what you are seeing.

If you set the printer as default through the GUI, the registry setting will match the case. If you use Kix and do not match the case exactly as the gui, it will cause the issue that the poster was having. In other words, kix sets the registry setting to match what you type in the script, not what is in the GUI.

Wscript somehow knows that if you do not match the case of the gui, it will transform it in the registry to match.

Does that help?




Top
#205738 - 2012-09-12 12:16 PM Re: SetDefaultPrinter bug [Re: Allen]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Ah.... now I understand... Apparently the application is case sensitive as far as the default printer name is concerned.

Ok, that's an easy thing to fix, this will be in the next 4.63 build.

Thanks for explaining the issue!!

Ruud

Top
#205764 - 2012-09-15 01:25 PM Re: SetDefaultPrinter bug [Re: Ruud van Velsen]
Robdutoit Offline
Hey THIS is FUN
***

Registered: 2012-03-27
Posts: 363
Loc: London, England
To Ruud, Just so that you know, I have gone down the route of using
 Code:
Dim $net
$net = CreateObject("wscript.network")
$net.SetDefaultPrinter($ServerName + "\" + $printsetup) 
etc etc etc


so I am not too fussed about the setdefaultprinter bug as only affects one old program, which is only used by one or two of my clients. However, having said that, as the function is not matching what happens when you manually set the printer - i.e. the correct case is entered into the registry, it probably makes sense to fix it so it does exactly what the manual setting does.
Thanks Rob

Top
Page 2 of 2 <12


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

Who's Online
0 registered and 662 anonymous users online.
Newest Members
Audio, Hoschi, Comet, rrosell, PatrickPinto
17880 Registered Users

Generated in 0.068 seconds in which 0.028 seconds were spent on a total of 14 queries. Zlib compression enabled.