Page 1 of 1 1
Topic Options
#38164 - 2003-03-21 07:54 AM Computers won't default to designated printers
Tim Grech Offline
Lurker

Registered: 2003-03-21
Posts: 4
Loc: Sydney, Australia
I am new to Kixtart. Our IT consultant (who we pay heaps) has installed kixtart for our default printer scripting.

All of a sudden two organisational units' computers (W2kServer AD) sometimes won't default to their designated printer. They default to usually two other particular printers in our work place (of at least 10-15).

The script looks OK to me, here it is in full as requested
*************************************************
;XXXX Logon Script 10/9/01 Created XXXXX XXXXXXXXXXXX"
;modified 13/11/01

if @wksta = "lib-1" goto "library"
else if @wksta = "lib-2" goto "library"
else if @wksta = "lib-3" goto "library"
else if @wksta = "lib-4" goto "library"
else if @wksta = "lib-5" goto "library"
else if @wksta = "lib-6" goto "library"
else if @wksta = "lib-7" goto "library"
else if @wksta = "lib-8" goto "library"
else if @wksta = "lib-9" goto "library"
else if @wksta = "lib-10" goto "library"
else if @wksta = "lib-11" goto "library"
else if @wksta = "lib-12" goto "library"
else if @wksta = "lib-13" goto "library"
else if @wksta = "lib-14" goto "library"
else if @wksta = "lib-15" goto "library"
else if @wksta = "lib-16" goto "library"
else if @wksta = "lib-17" goto "library"
else if @wksta = "lib-18" goto "library"
else if @wksta = "lib-19" goto "library"
else if @wksta = "lib-20" goto "library"
else if @wksta = "lib-21" goto "library" else goto "next"

:next
if @Wksta = "libLoft-1" goto "loft"
else if @wksta = "libLoft-2" goto "loft"
else if @wksta = "libLoft-3" goto "loft"
else if @wksta = "libLoft-4" goto "loft"
else if @wksta = "libLoft-5" goto "loft"
else if @wksta = "libLoft-6" goto "loft"
else if @wksta = "libLoft-7" goto "loft"
else if @wksta = "libLoft-8" goto "loft"
else if @wksta = "libLoft-9" goto "loft"
else if @wksta = "libLoft-10" goto "loft"
else if @wksta = "libLoft-11" goto "loft"
else if @wksta = "libLoft-12" goto "loft"
else if @wksta = "libLoft-13" goto "loft"
else if @wksta = "libLoft-14" goto "loft"
else if @wksta = "libLoft-15" goto "loft"
else if @wksta = "libLoft-16" goto "loft"
else if @wksta = "libLoft-17" goto "loft"
else if @wksta = "libLoft-18" goto "loft"
else if @wksta = "libLoft-19" goto "loft"
else if @wksta = "libLoft-20" goto "Loft" else goto "next1"

:next1
if @Wksta = "E5-1" goto "e5"
else if @Wksta = "E5-2" goto "e5"
else if @Wksta = "E5-3" goto "e5"
else if @Wksta = "E5-4" goto "e5"
else if @Wksta = "E5-5" goto "e5"
else if @Wksta = "E5-6" goto "e5"
else if @Wksta = "E5-7" goto "e5"
else if @Wksta = "E5-8" goto "e5"
else if @Wksta = "E5-9" goto "e5"
else if @Wksta = "E5-10" goto "e5"
else if @Wksta = "E5-11" goto "e5"
else if @Wksta = "E5-12" goto "e5"
else if @Wksta = "E5-13" goto "e5"
else if @Wksta = "E5-14" goto "e5"
else if @Wksta = "E5-15" goto "e5"
else if @Wksta = "E5-16" goto "e5"
else if @Wksta = "E5-17" goto "e5"
else if @Wksta = "E5-18" goto "e5"
else if @Wksta = "E5-19" goto "e5"
else if @Wksta = "E5-20" goto "e5" else goto "next2"

:next2
if @Wksta = "W9-1" goto "w9"
else if @Wksta = "W9-2" goto "w9"
else if @Wksta = "W9-3" goto "w9"
else if @Wksta = "W9-4" goto "w9"
else if @Wksta = "W9-5" goto "w9"
else if @Wksta = "W9-6" goto "w9"
else if @Wksta = "W9-7" goto "w9"
else if @Wksta = "W9-8" goto "w9"
else if @Wksta = "W9-9" goto "w9"
else if @Wksta = "W9-10" goto "w9"
else if @Wksta = "W9-11" goto "w9"
else if @Wksta = "W9-12" goto "w9"
else if @Wksta = "W9-13" goto "w9"
else if @Wksta = "W9-14" goto "w9"
else if @Wksta = "W9-15" goto "w9"
else if @Wksta = "W9-16" goto "w9"
else if @Wksta = "W9-17" goto "w9"
else if @Wksta = "W9-18" goto "w9"
else if @Wksta = "W9-19" goto "w9"
else if @Wksta = "W9-20" goto "w9" else goto "next5"

:next3
;if @Wksta = "admin-1" goto "admin"
;else if @Wksta = "admin-2" goto "admin"
;else if @Wksta = "admin-3" goto "admin"
;else if @Wksta = "admin-4" goto "admin"
;else if @Wksta = "admin-5" goto "admin"
;else if @Wksta = "admin-6" goto "admin"
;else if @Wksta = "admin-7" goto "admin"
;else if @Wksta = "admin-8" goto "admin"
;else if @Wksta = "admin-9" goto "admin"
;else if @Wksta = "admin-10" goto "admin" else goto "next4"

;:next4
;if @Wksta = "admin-11" goto "admin1"
;else if @Wksta = "admin-12" goto "admin1"
;else if @Wksta = "admin-13" goto "admin1"
;else if @Wksta = "admin-14" goto "admin1"
;else if @Wksta = "admin-15" goto "admin1"
;else if @Wksta = "admin-16" goto "admin1"
;else if @Wksta = "admin-17" goto "admin1"
;else if @Wksta = "admin-18" goto "admin1"
;else if @Wksta = "admin-19" goto "admin1"
;else if @Wksta = "admin-20" goto "admin1" elso goto "next5"

:next5
if @Wksta = "LSF-2" goto "LASERJET"
else if @Wksta = "ENGLISH-1" goto "LASERJET"
else if @Wksta = "SOCIALSCIENCE-1" goto "LASERJET"
else if @Wksta = "HISTORY-2" goto "LASERJET"
else if @Wksta = "PE-1" goto "LASERJET"
else if @Wksta = "SCIENCE-2" goto "LASERJET"
else if @Wksta = "LANGUAGES-1" goto "LASERJET"
else if @Wksta = "MATHS-2" goto "LASERJET"
else if @Wksta = "TAS-1" goto "LASERJET"
else if @Wksta = "HTADMIN-1" goto "LASERJET" else goto "next6"

:Next6
if @Wksta = "LSF-1" goto "LASERJET1"
else if @Wksta = "ENGLISH-2" goto "LASERJET2"
else if @Wksta = "SOCIALSCIENCE-2" goto "LASERJET3"
else if @Wksta = "HISTORY-1" goto "LASERJET4"
else if @Wksta = "PE-2" goto "LASERJET5"
else if @Wksta = "SCIENCE-1" goto "LASERJET6"
else if @Wksta = "LANGUAGES-2" goto "LASERJET7"
else if @Wksta = "MATHS-1" goto "LASERJET8"
else if @Wksta = "TAS-2" goto "LASERJET9"
else if @Wksta = "HTADMIN-2" goto "LASERJET10" else goto "next7"

:Next8
MESSAGEBOX ("PLEASE CHECK YOUR PRINTER SETTINGS BEFORE PRINTING!","DEFAULT PRINTER",0,5)
goto "end"

:library
ADDPRINTERCONNECTION ("\\ALPHA\LIBRARY")
SETDEFAULTPRINTER ("\\ALPHA\LIBRARY")
MESSAGEBOX ("Your Default Printer it set to LIBRARY","DEFAULT PRINTER",0,5)
goto "end"

:loft
ADDPRINTERCONNECTION ("\\ALPHA\LOFT")
SETDEFAULTPRINTER ("\\ALPHA\LOFT")
MESSAGEBOX ("Your Default Printer it set to LOFT","DEFAULT PRINTER",0,5)
goto "end"

:e5
ADDPRINTERCONNECTION ("\\ALPHA\E5")
SETDEFAULTPRINTER ("\\ALPHA\E5")
MESSAGEBOX ("Your Default Printer it set to E5","DEFAULT PRINTER",0,5)
goto "end"

:W9
ADDPRINTERCONNECTION ("\\ALPHA\W9")
SETDEFAULTPRINTER ("\\ALPHA\W9")
MESSAGEBOX ("Your Default Printer it set to W9","DEFAULT PRINTER",0,5)
goto "end"

:admin
ADDPRINTERCONNECTION ("\\ALPHA\ADMIN")
SETDEFAULTPRINTER ("\\ALPHA\ADMIN")
MESSAGEBOX ("Your Default Printer it set to ADMIN","DEFAULT PRINTER",0,5)
goto "end"

:admin1
ADDPRINTERCONNECTION ("\\ALPHA\ADMIN1")
SETDEFAULTPRINTER ("\\ALPHA\ADMIN1")
MESSAGEBOX ("Your Default Printer it set to ADMIN1","DEFAULT PRINTER",0,5)
goto "end"

:w3
ADDPRINTERCONNECTION ("\\ALPHA\W3")
SETDEFAULTPRINTER ("\\ALPHA\W3")
MESSAGEBOX ("Your Default Printer it set to W3","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET
SETDEFAULTPRINTER ("LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet (Local)","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET1
SETDEFAULTPRINTER ("\\LSF-2\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on LSF-2)","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET2
SETDEFAULTPRINTER ("\\ENGLISH-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on ENGLISH-1)","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET3
SETDEFAULTPRINTER ("\\SOCIALSCIENCE-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on SOCIALSCIENCE-1)","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET4
SETDEFAULTPRINTER ("\\HISTORY-2\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on HISTORY-2)","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET5
SETDEFAULTPRINTER ("\\PE-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on PE-1)","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET6
SETDEFAULTPRINTER ("\\SCIENCE-2\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on SCIENCE-2)","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET7
SETDEFAULTPRINTER ("\\LANGUAGES-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on LANGUAGES-1)","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET8
SETDEFAULTPRINTER ("\\MATHS-2\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on MATHS-2)","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET9
SETDEFAULTPRINTER ("\\TAS-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on TAS-1)","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET10
SETDEFAULTPRINTER ("\\HTADMIN-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on HTADMIN-1)","DEFAULT PRINTER",0,5)
goto "end"

:end
endif
**************************************************

I am assuming in the next5 bunch of statements all the printers are called LASERJET (without a number) because the printer is connected to that computer and LASERJET is the default name in LPT1 whereas in the next6 bunch of lines each printer has a number (ie LASERJET2).

It only defaults to the wrong printer sometimes and the old fuddies at my work can't handle this!

Any ideas? Sounds like a profiles problem? Do I need to add more info? Happens to all users but same computers.

[ 24. March 2003, 08:33: Message edited by: Tim Grech ]

Top
#38165 - 2003-03-21 10:10 AM Re: Computers won't default to designated printers
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
uhm...
10-15 wksta's you say.

could you place the whole script here?
we could check it and remove the some errenous code and fix it and polish it [Wink]

at least the goto structure should have a remove and probably also the if-else thing should be cleared.
_________________________
!

download KiXnet

Top
#38166 - 2003-03-21 10:12 AM Re: Computers won't default to designated printers
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Hello Tim and welcome to the board.

It could be a lot of things. It could be that someone was messing with policies.

Please answer a few questions first.

1. What version of KiXtart are you using?
2. What client OS do you support? 9x/nt/2000?
3. When did the problem start?
4. Did anyone admit changing anything?
5. Please post your BATCH file that launches KiXtart
6. Please post the complete KiX script

When posting please use the Instant UBB buttons to enclose your batch and then your script within the [ code ] tags.... this will keep the formatting of your script for us to look at and give you further advice.

Top
#38167 - 2003-03-21 03:12 PM Re: Computers won't default to designated printers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Just taking a cursory look at the script your consultant produced, I'd say it's time to let him go and do it yourself. I can't believe that he maps default printers by checking each computername in multiple IFs and then uses GOTOs to jump all over the place inside that script.

There are more effecive, elegant and, simpler ways to accomplish this. One way would be, yes, my favirote toy, the .INI file:
code:
; printers.ini
[Defaults]
LASERJET=LSF-2,LSF-4,LSF-6
LASERJET1=LSF-1,LSF-3,LSF-5

KiXtart:
code:
; KiXtart 4.20
$defaultprinters=split(readprofilestring('printers.ini','Defaults',''),chr(10))
for each $printer in $$defaultprinters
$comps=split($readprofilestring('printers.ini','Defaults'$printer),chr(10))
if ascan($comps,@WKSTA)
$rc=setdefaultprinter($printer)
endif
next

This is just a framework, there are other ways to do this.

[ 21. March 2003, 15:13: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#38168 - 2003-03-24 09:03 AM Re: Computers won't default to designated printers
Tim Grech Offline
Lurker

Registered: 2003-03-21
Posts: 4
Loc: Sydney, Australia
In answer to some questions

1. I'm using Kix32 (I think)
2. We only have 200 clients but can supprot others
3. Problem started about 4-5months ago (after we got some more computers & printers (significant??))
4. Nobody admits to anything!
5.
6. Complete script above

How could it be a poliy problem? Sounds interesting.

Top
#38169 - 2003-03-24 09:31 AM Re: Computers won't default to designated printers
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Tim,

I wonder why it should work anyway (there is only 1 endif for several ifs)

Well if this is all the code it evaluates before failing , but still this is a bad piece of code

You might consider Jens' snippet above to start with
_________________________



Top
#38170 - 2003-03-24 09:35 AM Re: Computers won't default to designated printers
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
I've got another question now after seeing the script.

Why do you (or anyone) install and set a default printer during login EVERY TIME the user logs on. Unless it is a roaming profile or something... this sure seems like a waste of time and bandwidth. i.e. If I log off and back on 10 times during the course of the day... the logon script would remap my printer over and over.

If you're using AD which you say, you can set a GPO that assigns printers based on membership in an OU.

There are other ways of doing this much cleaner as well. Jens likes to use .ini files which seem to work quite well.

Doing nothing else with cleaning your script up, I'd opt to use SELECT CASE statements over that many IFs Just looks cleaner to me.

But as it appears it is done by workstation name. Set it once and forget it, or use the .INI method.

I'll leave any further ideas/code to others as there are many ways of doing it, I just don't see why its being done in the first place. Set it, and forget it. Also, this is KiXtart scripting, not batch scripting. All these NEXT label statements are over kill.

[ 24. March 2003, 09:36: Message edited by: NTDOC ]

Top
#38171 - 2003-03-24 11:20 AM Re: Computers won't default to designated printers
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I didn't find the ":next7" which is called there...

anyway, I don't get it either.
if you need to map aren't those maps done for users?

and looking at amount, if you need to have maps per-computer in AD, you have the best possibilities listed above.
_________________________
!

download KiXnet

Top
#38172 - 2003-03-24 03:29 PM Re: Computers won't default to designated printers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Did I even mention that I hate GOTOs?

That script needs a complete rework, it actually hurts my eyes to see this produced by an 'IT Consultant'.
_________________________
There are two types of vessels, submarines and targets.

Top
#38173 - 2003-03-25 05:02 AM Re: Computers won't default to designated printers
MCA Offline
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 ]
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#38174 - 2003-03-25 07:27 AM Re: Computers won't default to designated printers
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
One comment with the 1 thru 20/21 thing, why not use a FOR..NEXT with a counter? That would be even cleaner.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#38175 - 2003-03-25 08:25 AM Re: Computers won't default to designated printers
Tim Grech Offline
Lurker

Registered: 2003-03-21
Posts: 4
Loc: Sydney, Australia
WOW!

I'll have to study your replies and scripts more closely - I only looked at the manual the first tim last week!

I beleieve you all that it is messy, but will it work? It seems to work all the time except for the two organisational untits where the LSF and MATHS computers are held.

Our IT Consultant suggested wiping off all the printers in Control Panel and reinstalling only the one we need for the computers affected. Could windows/kixstart be getting confused because there are many printers installed/added by one user? I'm just not sure yet if it's a problem with the script.

In answer to NTDOC, yes we do use roaming profiles, that is why we set default printer at every log in (this makes sense to me but I'm sure I'll be shown the light by somebody). This has been highly educational!

Top
#38176 - 2003-03-25 08:43 AM Re: Computers won't default to designated printers
Tim Grech Offline
Lurker

Registered: 2003-03-21
Posts: 4
Loc: Sydney, Australia
I actually thought it was very easy to read and figure out what was going on. Maybe that's why it's done this way.
Top
#38177 - 2003-03-25 09:08 AM Re: Computers won't default to designated printers
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Tim,

Looked at your code a bit..

Here is the re-worked version (untested, but you get the idea) [Smile]

code:
CLS
BREAK ON
DIM $i

FOR $i=1 TO 21
IF @wksta = 'lib-'+$i
ADDPRINTERCONNECTION ("\\ALPHA\LIBRARY")
SETDEFAULTPRINTER ("\\ALPHA\LIBRARY")
MESSAGEBOX ("Your Default Printer it set to LIBRARY","DEFAULT PRINTER",0,5)
QUIT
ENDIF
NEXT

FOR $i=1 TO 20
IF @wksta = 'libLoft-'+$i
ADDPRINTERCONNECTION ("\\ALPHA\LOFT")
SETDEFAULTPRINTER ("\\ALPHA\LOFT")
MESSAGEBOX ("Your Default Printer it set to LOFT","DEFAULT PRINTER",0,5)
QUIT
ENDIF
NEXT

FOR $i=1 TO 20
IF @wksta = 'E5-'+$i
ADDPRINTERCONNECTION ("\\ALPHA\E5")
SETDEFAULTPRINTER ("\\ALPHA\E5")
MESSAGEBOX ("Your Default Printer it set to E5","DEFAULT PRINTER",0,5)
QUIT
ENDIF
NEXT

FOR $i=1 TO 20
IF @wksta = 'W9-'+$i
ADDPRINTERCONNECTION ("\\ALPHA\W9")
SETDEFAULTPRINTER ("\\ALPHA\W9")
MESSAGEBOX ("Your Default Printer it set to W9","DEFAULT PRINTER",0,5)
QUIT
ENDIF
NEXT

$name = Split("LSF-2~ENGLISH-1~SOCIALSCIENCE-1~HISTORY-2~PE-1~SCIENCE-2~LANGUAGES-1~MATHS-2~TAS-1~HTADMIN-1","~")

FOR EACH $element IN $name
IF @wksta = $element
SETDEFAULTPRINTER ("LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet (Local)","DEFAULT PRINTER",0,5)
QUIT
ENDIF
NEXT

SELECT
CASE
@wksta = "LSF-1" MAPPRINT("\\LSF-2\LASERJET","LSF-2")
CASE
@wksta = "ENGLISH-2" MAPPRINT("\\ENGLISH-1\LASERJET","\\ENGLISH-1")
CASE
@wksta = "SOCIALSCIENCE-2" MAPPRINT("\\SOCIALSCIENCE-1\LASERJET","\\SOCIALSCIENCE-1")
CASE
@wksta = "HISTORY-1" MAPPRINT("\\HISTORY-2\LASERJET","\\HISTORY-2")
CASE
@wksta = "PE-2" MAPPRINT("\\PE-1\LASERJET","\\PE-1")
CASE
@wksta = "SCIENCE-1" MAPPRINT("\\SCIENCE-2\LASERJET","\\SCIENCE-2")
CASE
@wksta = "LANGUAGES-2" MAPPRINT("\\LANGUAGES-1\LASERJET","\\LANGUAGES-1")
CASE
@wksta = "MATHS-1" MAPPRINT("\\MATHS-2\LASERJET","\\MATHS-2")
CASE
@wksta = "TAS-2" MAPPRINT("\\TAS-1\LASERJET","\\TAS-1")
CASE
@wksta = "HTADMIN-2" MAPPRINT("\\HTADMIN-1\LASERJET","\\HTADMIN-1")
ENDSELECT

:next8
MESSAGEBOX ("PLEASE CHECK YOUR PRINTER SETTINGS BEFORE PRINTING!","DEFAULT PRINTER",0,5)
QUIT

FUNCTION MAPPRINT($defprtr,$ptrname)
SETDEFAULTPRINTER ($defprtr)
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on "+$ptrname+")","DEFAULT PRINTER",0,5)
QUIT
ENDFUNCTION

:w3
ADDPRINTERCONNECTION ("\\ALPHA\W3")
SETDEFAULTPRINTER ("\\ALPHA\W3")
MESSAGEBOX ("Your Default Printer it set to W3","DEFAULT PRINTER",0,5)
QUIT

:END

The only caveat to this change-over, you will need KiXtart version 4.x or better to run this.

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#38178 - 2003-03-25 03:45 PM Re: Computers won't default to designated printers
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
tim, you should say good-bye to that IT-consultant.

it's obvious he is some dude from backstreet-boys and has no knowledge about computers whatsoever.

I even bet he works for IBM!
_________________________
!

download KiXnet

Top
#38179 - 2003-03-25 03:50 PM Re: Computers won't default to designated printers
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Not necessarily ... IT-Consultants are kinda dumb-by-definition (At least the average one)

Hmmm .. strange enough why the average Income is that high [Confused]

[ 25. March 2003, 15:52: Message edited by: jpols ]
_________________________



Top
#38180 - 2003-03-25 04:17 PM Re: Computers won't default to designated printers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
An alternative is .INI files:
code:
[Printers]
lib=\\ALPHA\LIBRARY

I would highly recommend that you rething the priner mappinsg to take advantage of our proposals to e.g. use. INI files or other measn to associate specific printers with specific groups of computers.
_________________________
There are two types of vessels, submarines and targets.

Top
#38181 - 2003-03-28 01:09 AM Re: Computers won't default to designated printers
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear Kent,

We were using this code, because it is possible that they run it on a Kixtart 3.x release.
See our remark about label "next".
Also it was the reason we are using an UDF.

Of course with the latest Kixtart functionalities we can reduce our script also.

greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#38182 - 2003-03-28 05:25 PM Re: Computers won't default to designated printers
a_non_moose Offline
Fresh Scripter

Registered: 2002-05-03
Posts: 17
Loc: UGA
Nothing to add, except for the word "consultant" brought this to mind: http://www.thinkgeek.com/cubegoodies/posters/despair/58fc/

Heh.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1452 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.161 seconds in which 0.079 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org