#204781 - 2012-04-19 07:41 PM
Re: SetDefaultPrinter bug
[Re: Allen]
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Does this work?
$ServerName = LCase(@LServer)
SetDefaultPrinter ($ServerName + "\ICT Colour"
|
Top
|
|
|
|
#204795 - 2012-04-19 08:59 PM
Re: SetDefaultPrinter bug
[Re: ShaneEP]
|
Lonkero
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
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
|
|
|
|
#204807 - 2012-04-20 03:16 AM
Re: SetDefaultPrinter bug
[Re: Lonkero]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4557
Loc: USA
|
This is interesting...
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.
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
|
|
|
|
#204838 - 2012-04-21 12:50 PM
Re: SetDefaultPrinter bug
[Re: Lonkero]
|
Robdutoit
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
|
|
|
|
#205764 - 2012-09-15 01:25 PM
Re: SetDefaultPrinter bug
[Re: Ruud van Velsen]
|
Robdutoit
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
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
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 669 anonymous users online.
|
|
|