#38173 - 2003-03-25 05:02 AM
Re: Computers won't default to designated printers
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
First, a great welcome to this board.
It is a pity, that your organization is playing a great amount of money, when he had made those changes or when he had implement kixtart in your organization with such a script.
First we verify your script version with our tool kixstrip, which you can find on our site. During the call
kixstrip input.kix output.kix /block_check
we get following output on the screen
code:
Kixstrip 4.20 (vs 4.00e) (c) MCA - scripting@wanadoo.nl - 2003 Kixstrip 4.20 (vs 4.00e) 0.76 (sec)
input 243 input.kix output 243 output.kix (skip: 0 blocks: 0 labels: 26) block_check -ERROR- block_errors=100 block_structures=101 labels=26 tab=6 (default)
Warning KIXSTRIP: 100 errors in block structure(s). missing statement(s). - do:until [0:0] - for|each:in|to:step|next [0|0:0|0:0|0] - function:endfunction [0:0] -ERROR- - if:else:endif [101:101:1] - select:case:endselect [0:0:0] - while:loop [0:0] 101 block_structures found. Informative KIXSTRIP: no UDF's found. Warning KIXSTRIP: some lines contains errors or possible errors.
active options: /Block_Check /Headers /Print /Show_Structure /TAB=6 /Translate inactive options: /NoCombine /NoDebug /NoPerformance /NoProgress /NoShow_Errors /NoLicense: (not.specified)
Some of our remarks:
- indeed missing the "next7" label.
- script can't run on kixtart 4.x releases. You are using "NEXT" as a label.
- very bad IF/ELSE/ENDIF structure.
- with the great amount of GOTO's it is hard to read what is really going on.
- "admin"-part became comment. strange way of doing.
- "next8" label not reachable.
- "w3" label not reachable. selection on a W3-group also not there.
After some modifications we get following script, which should run on different kixtart 3.6x and 4.x releases. In our version we are using different kind of lists. As separator between workstations we are using the "="-symbol. It will prevent problems with names like "lib-1" and "lib-11", "lib-12", ..., "lib-19", etc. In the SELECT/CASE/ENDSELECT we are setting some variables, which we are using in the GOSUB procedure. Also we have include some error handling. Error handling to make it much easier to see what is going wrong. Our version:
code:
;XXXX Logon Script 10/9/01 Created XXXXX XXXXXXXXXXXX" ; ; last modified 25 March 2003
$wksta=@wksta GOSUB check_printer EXIT :check_printer $lib_list="=lib-1=lib-2=lib-3=lib-4=lib-5=lib-6=lib-7=lib-8=lib-9=lib-10="+ "=lib-11=lib-12=lib-13=lib-14=lib-15=lib-16=lib-17=lib-18=lib-19=lib-20="+ "=lib-21=" $libLoft_list="=libLoft-1=libLoft-2=libLoft-3=libLoft-4=libLoft-5=libLoft-6=libLoft-7=libLoft-8=libLoft-9=libLoft-10="+ "=libLoft-11=libLoft-12=libLoft-13=libLoft-14=libLoft-15=libLoft-16=libLoft-17=libLoft-18=libLoft-19=libLoft-20=" $E5_list="=E5-1=E5-2=E5-3=E5-4=E5-5=E5-6=E5-7=E5-8=E5-9=E5-10="+ "=E5-11=E5-12=E5-13=E5-14=E5-15=E5-16=E5-17=E5-18=E5-19=E5-20=" $W9_list="=w9-1=w9-2=w9-3=w9-4=w9-5=w9-6=w9-7=w9-8=w9-9=w9-10="+ "=w9-11=w9-12=w9-13=w9-14=w9-15=w9-16=w9-17=w9-18=w9-19=w9-20=" $laserjet1_list="=LSF-2=ENGLISH-1=SOCIALSCIENCE-1=HISTORY-2=PE-1=SCIENCE-2=LANGUAGES-1=MATHS-2=TAS-1=HTADMIN-1=" $laserjet2_list="=LSF-1=ENGLISH-2=SOCIALSCIENCE-2=HISTORY-1=PE-2=SCIENCE-1=LANGUAGES-2=MATHS-1=TAS-2=HTADMIN-2=" ; $printer="" $printer_name="" SELECT CASE (Instr($lib_list, "="+$wksta+"=") <> 0) ; lib-1 .. lib-21 $printer="LIBRARY" $printer_name="\\ALPHA\LIBRARY" CASE (Instr($libLoft_list, "="+$wksta+"=") <> 0) ; libLoft-1 .. libLoft-20 $printer="LOFT" $printer_name="\\ALPHA\LOFT" CASE (Instr($E5_list, "="+$wksta+"=") <> 0) ; E5-1 .. E5-20 $printer="E5" $printer_name="\\ALPHA\E5" CASE (Instr($w9_list, "="+$wksta+"=") <> 0) ; w9-1 .. w9-20 $printer="W9" $printer_name="\\ALPHA\W9" CASE (Instr($laserjet1_list, "="+$wksta+"=") <> 0) ; lsf-2 .. htadmin-1 $printer="" $printer_name="LASERJET" ; - connecting to "HP LaserJet (Local)" CASE (Instr($laserjet2_list, "="+$wksta+"=") <> 0) ; lsf-1 .. htadmin-2 $printer=Substr($laserjet1_list, Instr($laserjet2_list, "="+$wksta+"=")+1, Len($wksta)) $printer_name="\\$printer\LASERJET" CASE 1 $=MessageBox("Problems with finding a printer for you","Warning about setting Default Printer",0,5) ENDSELECT IF ($printer <> "") OR ($printer_name <> "") GOSUB set_default_printer ENDIF RETURN :set_default_printer ? "Try to Set '$printer' / '$printer_name' for workstation '$wksta'" IF ($printer <> "") IF (AddPrinterConnection("$printer_name") <> 0) $=MessageBox("Problems with connection your default printer $printer"+CHR(13)+"error code @error (@serror)","Warning about setting Default Printer",0,5) ELSE IF (SetDefaultPrinter("$printer_name") <> 0) $=MessageBox("Problems with setting your default printer $printer"+CHR(13)+"error code @error (@serror)","Warning about setting Default Printer",0,5) ELSE $=MessageBox("Your Default Printer it set to $printer","Info about setting Default Printer",0,5) ENDIF ENDIF ELSE IF (SetDefaultPrinter("$printer_name") <> 0) $=MessageBox("Problems with setting your default printer $printer_name (local)"+CHR(13)+"error code @error (@serror)","Warning about setting Default Printer",0,5) ELSE $=MessageBox("Your Default Printer it set to $printer_name (local)","Info about setting Default Printer",0,5) ENDIF ENDIF ;$=MessageBox("Please check your printer settings before printing!","Info about setting Default Printer",0,5) RETURN
For testing we have include following lines at the beginning
code:
$wksta="lib-9" GOSUB check_printer $wksta="libLoft-15" GOSUB check_printer $wksta="E5-5" GOSUB check_printer $wksta="w9-17" GOSUB check_printer $wksta="LSF-1" GOSUB check_printer $wksta="LSF-2" GOSUB check_printer $wksta="PE-1" GOSUB check_printer $wksta="PE-2" GOSUB check_printer EXIT
Output in DOS box is
code:
Try to Set 'LIBRARY' / '\\ALPHA\LIBRARY' for workstation 'lib-9' Try to Set 'LOFT' / '\\ALPHA\LOFT' for workstation 'libLoft-15' Try to Set 'E5' / '\\ALPHA\E5' for workstation 'E5-5' Try to Set 'W9' / '\\ALPHA\W9' for workstation 'w9-17' Try to Set 'LSF-2' / '\\LSF-2\LASERJET' for workstation 'LSF-1' Try to Set '' / 'LASERJET' for workstation 'LSF-2' Try to Set '' / 'LASERJET' for workstation 'PE-1' Try to Set 'PE-1' / '\\PE-1\LASERJET' for workstation 'PE-2'
greetings. btw: of course it is possible to reduce this script, but we were going for the newbies. [ 25. March 2003, 05:04: Message edited by: MCA ]
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1471 anonymous users online.
|
|
|