#147541 - 2005-09-13 01:13 PM
Re: printer add: need help...
|
balafrus
Fresh Scripter
Registered: 2005-09-12
Posts: 33
Loc: Belgium
|
Excuse me but is your script for Kix 4xx or kix 3xx ?
Cause i got some error messages at startup and cant see them cause of their speed... 
BAL.
|
Top
|
|
|
|
#147544 - 2005-09-13 01:41 PM
Re: printer add: need help...
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
alrighty! now, if I understood all the pieces properly, all you need for all classes could be...
Code:
;Room XXX ;wksta: PTExXXXayy ;Printer laser: HPlaserjetXXX ;printer colour: hpXXX ;serveur: PTPServerName
if substr(@wksta,1,3) = "PTE" $Room = substr(@wksta,4,4) if substr($Room,1,1) = "0" $Room = substr($Room,2) endif ;if number begins with zero, remove it. $retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room) $retval = AddPrinterConnection("\\PTPServerName\HP"+$Room) endif
that same code works for all rooms. now, if you want to make the laser the default (as example), you need to have the name of the printer instead of the sharename. if your sharename and printername on the server are the same, then simply this will do: Code:
if substr(@wksta,1,3) = "PTE" $Room = substr(@wksta,4,4) if substr($Room,1,1) = "0" $Room = substr($Room,2) endif ;if number begins with zero, remove it. $retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room) $retval = SetDefaultPrinter("\\PTPServerName\HPlaserjet"+$Room) $retval = AddPrinterConnection("\\PTPServerName\HP"+$Room) endif
and that's it. there is 7 lines but heck... little extra for 3.xx 
you understand what I did there?
_________________________
!download KiXnet
|
Top
|
|
|
|
#147546 - 2005-09-13 04:45 PM
Re: printer add: need help...
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
it does not matter. I thought about it too before posted the code. when there is no printer, the addprinterconnection just fails to connect the printer, right? so, it's fine to be there.
for 706 the problem is there. you have 2 choices. either share the same printer again with another name too or I will modify the script.
you could have something like: Code:
if substr(@wksta,1,3) = "PTE" $Room = substr(@wksta,4,4) if substr($Room,1,1) = "0" $Room = substr($Room,2) endif if $Room = "706" $Room = "705" endif ;706 does not have printer, using the one from 705. $retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room) $retval = SetDefaultPrinter("\\PTPServerName\HPlaserjet"+$Room) $retval = AddPrinterConnection("\\PTPServerName\HP"+$Room) endif
_________________________
!download KiXnet
|
Top
|
|
|
|
#147547 - 2005-09-15 09:04 AM
Re: printer add: need help...
|
balafrus
Fresh Scripter
Registered: 2005-09-12
Posts: 33
Loc: Belgium
|
nice one , i will try this and tell you if it works... !
Thanks a lot !
BAL. (ps: i take my 2nd "C" training yesterday...so please be patient.. )
|
Top
|
|
|
|
#147550 - 2005-09-15 10:05 AM
Re: printer add: need help...
|
balafrus
Fresh Scripter
Registered: 2005-09-12
Posts: 33
Loc: Belgium
|
rhooo thanks a lot it will help me more then u can think about.... 
BAL.
|
Top
|
|
|
|
#147554 - 2005-09-15 10:54 AM
Re: printer add: need help...
|
balafrus
Fresh Scripter
Registered: 2005-09-12
Posts: 33
Loc: Belgium
|
oh , ok im thinking about a more evil code like this
Code:
break if substr(@wksta,1,3) = "PTE" break on $Room = substr(@wksta,4,4) if substr($Room,1,1) = "0" $Room = substr($Room,2) endif if $Room = "706" $Room = "705" endif ;706 does not have printer, using the one from 705. $retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room) $retval = SetDefaultPrinter("\\PTPServerName\HPlaserjet"+$Room) $retval = AddPrinterConnection("\\PTPServerName\HP"+$Room) endif
Or something like that...
BAL.
|
Top
|
|
|
|
#147555 - 2005-09-15 11:06 AM
Re: printer add: need help...
|
balafrus
Fresh Scripter
Registered: 2005-09-12
Posts: 33
Loc: Belgium
|
here's what i've tried and don't seems to work...
Code:
break on
if substr(@wksta,1,3) = "PTE" $Room = substr(@wksta,4,4) if substr($Room,1,1) = "0" $Room = substr($Room,2) endif ; $retval = AddPrinterConnection("\\PTE0705A06\HP"+$Room) $retval = SetDefaultPrinter("\\PTP0705A06\HP"+$Room) endif
Isn't it suppose to connect a printer ? i try this one with kixtart version 4.50 any idea ?
BAL.
|
Top
|
|
|
|
#147556 - 2005-09-15 11:38 AM
Re: printer add: need help...
|
balafrus
Fresh Scripter
Registered: 2005-09-12
Posts: 33
Loc: Belgium
|
ok i try this one and it works fine:
Code:
break on
if substr(@wksta,1,5) = "PTE07"; $retval = AddPrinterConnection("\\PTE0705A06\HP705") $retval = SetDefaultPrinter("\\PTE0705A06\HP705") endif
But still have some problems to set as a default printer...is the syntax correct ?
BAL.
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 581 anonymous users online.
|
|
|