Page 1 of 1 1
Topic Options
#188100 - 2008-06-07 01:15 AM Script not working: dies in the right spot!
smileyguy Offline
Fresh Scripter

Registered: 2008-06-07
Posts: 6
You will probably see this script is designed only for mapping printers depending on the workstation.

I have no scripting knowledge. This script was written for us ages ago by our old tecchie and we understand how to modify it so we don't want to change it to a more advanced one (I know it is apparently very rudimentary).

The problem is, the script gets to the right section/room for the workstation names (e.g., the "libloft" room or "E5" room) but it gets to the last statement for that section (the else statement - e.g., else if @wksta = "libLoft-25" goto "library" else goto "next1") and dies there. i can see this happening with the logon script being displayed on workstation logons and that line appearing red (the else if line). I have highlighted the first few examples f these lines in red. For some reason it dies in the right section (e.g., if the workstation is in room W9, the script dies at the else if statemtn in the W9 section).

All users are running Windows XPSP2 workstations and Windows Server 2003 SP1.

We recently upgraded to new servers and changed the server kixtart was installed on. none of the workstations had their names changed (wondering why it dies at the else statement).

If you have any ideas I will remember you in my will!

****************************

sleep 15


if @wksta = "lib-1" goto "library"
else 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 if @wksta = "mmc-1" goto "library"
else if @wksta = "mmc-2" goto "library"
else if @wksta = "mmc-3" goto "library"
else if @wksta = "mmc-4" goto "library"
else if @wksta = "mmc-5" goto "library"
else if @wksta = "mmc-6" goto "library"
else if @wksta = "mmc-7" goto "library"
else if @wksta = "mmc-8" goto "library"
else if @wksta = "mmc-9" goto "library"
else if @wksta = "mmc-10" goto "library"
else if @wksta = "mmc-11" goto "library"
else if @wksta = "mmc-12" goto "library"
else if @wksta = "tsc-1" goto "library" else goto "next"


:next
if @Wksta = "libLoft-1" goto "loft"
else if @wksta = "libLoft-2" goto "library"
else if @wksta = "libLoft-3" goto "library"
else if @wksta = "libLoft-4" goto "library"
else if @wksta = "libLoft-5" goto "library"
else if @wksta = "libLoft-6" goto "library"
else if @wksta = "libLoft-7" goto "library"
else if @wksta = "libLoft-8" goto "library"
else if @wksta = "libLoft-9" goto "library"
else if @wksta = "libLoft-10" goto "library"
else if @wksta = "libLoft-11" goto "library"
else if @wksta = "libLoft-12" goto "library"
else if @wksta = "libLoft-13" goto "library"
else if @wksta = "libLoft-14" goto "library"
else if @wksta = "libLoft-15" goto "library"
else if @wksta = "libLoft-16" goto "library"
else if @wksta = "libLoft-17" goto "library"
else if @wksta = "libLoft-18" goto "library"
else if @wksta = "libLoft-19" goto "library"
else if @wksta = "libLoft-20" goto "library"
else if @wksta = "libLoft-21" goto "library"
else if @wksta = "libLoft-22" goto "library"
else if @wksta = "libLoft-23" goto "library"
else if @wksta = "libLoft-24" goto "library"
else if @wksta = "libLoft-25" goto "library" 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 if @Wksta = "E5-teacher" 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 if @Wksta = "W9-teacher" goto "w9" else goto "next3"

:next3
if @Wksta = "W3-1" goto "w3"
else if @Wksta = "W3-2" goto "w3"
else if @Wksta = "W3-3" goto "w3"
else if @Wksta = "W3-4" goto "w3"
else if @Wksta = "W3-5" goto "w3"
else if @Wksta = "W3-6" goto "w3"
else if @Wksta = "W3-7" goto "w3"
else if @Wksta = "W3-8" goto "w3"
else if @Wksta = "W3-9" goto "w3"
else if @Wksta = "W3-10" goto "w3"
else if @Wksta = "W3-11" goto "w3"
else if @Wksta = "W3-12" goto "w3"
else if @Wksta = "W3-13" goto "w3"
else if @Wksta = "W3-14" goto "w3"
else if @Wksta = "W3-15" goto "w3"
else if @Wksta = "W3-16" goto "w3"
else if @Wksta = "W3-teacher" goto "w3" else goto "next4"


:next4
if @Wksta = "admin-1" goto "admin1"
else if @Wksta = "admin-2" goto "admin1"
else if @Wksta = "admin-3" goto "admin1" else goto "next5"


:next5
if @Wksta = "admin-4" goto "admin"
else if @Wksta = "admin-5" goto "admin"
else if @Wksta = "admin-6" goto "admin" else goto "next6"


:next6
if @Wksta = "PRINCIPAL" goto "LASERJET"
else if @Wksta = "DEPUTY-1" goto "LASERJET"
else if @Wksta = "DEPUTY-2" goto "LASERJET"
else if @Wksta = "ENGLISH-3" goto "LASERJET"
else if @Wksta = "PE-1" goto "LASERJET"
else if @Wksta = "PE-1b" goto "LASERJET"
else if @Wksta = "TIMETABLE" goto "LASERJET"
else if @Wksta = "TAS-1" goto "LASERJET"
else if @Wksta = "ART-1" goto "Lexmark1"
else if @Wksta = "SCIENCE-PREP" goto "LASERJET"
else if @Wksta = "HTWELFAREb" goto "LASERJET"
else if @Wksta = "HTADMIN-1" goto "LASERJET" else goto "next7"


:Next7
if @Wksta = "LANGUAGES-1" goto "LANGUAGES"
else if @Wksta = "LANGUAGES-2" goto "LANGUAGES"
else if @Wksta = "LSF-1" goto "lsf"
else if @Wksta = "LSF-2" goto "lsf"
else if @Wksta = "ENGLISH-2" goto "LASERJET2"
else if @Wksta = "HISTORY-1" goto "HISTORY"
else if @Wksta = "HISTORY-2" goto "HISTORY"
else if @Wksta = "HTLAPTOP-HIST" goto "HISTORY"
else if @Wksta = "PE-2" goto "LASERJET5"
else if @Wksta = "MATHS-1" goto "maths"
else if @Wksta = "MATHS-2" goto "maths"
else if @Wksta = "MATHS-3" goto "maths"
else if @Wksta = "MATHS-4" goto "maths"
else if @Wksta = "MATHS-3b" goto "maths"
else if @Wksta = "TAS-2" goto "LASERJET9"
else if @wksta = "MUSIC-1" goto "Lexmark1"
else if @wksta = "MUSIC-1" goto "Lexmark1"
else if @wksta = "ART-1" goto "ART"
else if @Wksta = "HTADMIN-2" goto "LASERJET10"
else if @Wksta = "SOCIALSCIENCE-1" goto "LASERJET11"
else if @Wksta = "SOCIALSCIENCE-2" goto "LASERJET11"
else if @Wksta = "SCIENCE-1" goto "SCIENCE"
else if @Wksta = "SCIENCE-2" goto "SCIENCE" else goto "next8"


:Next8
if @wksta = "ART-4" goto "COLORLASERJET"
else if @wksta = "ART-1" goto "COLORLASERJET1"
else if @wksta = "ART-2" goto "COLORLASERJET1"
else if @wksta = "ART-3" goto "COLORLASERJET1"
else if @wksta = "ART-5" goto "COLORLASERJET1"
else if @wksta = "ART-6" goto "COLORLASERJET1" else goto "next9"

:Next9
if @wksta = "C7-3" goto "LASERJET"
else if @wksta = "C7-1" goto "LASERJET12"
else if @wksta = "C7-2" goto "LASERJET12"
else if @wksta = "C7-3" goto "LASERJET12"
else if @wksta = "C7-4" goto "LASERJET12" else goto "next10"

:next10
if @wksta = "S15-1" goto "S15"
else if @wksta = "S15-2" goto "S15"
else if @wksta = "S15-3" goto "S15"
else if @wksta = "S15-4" goto "S15"
else if @wksta = "S15-5" goto "S15"
else if @wksta = "S15-6" goto "S15"
else if @wksta = "S15-7" goto "S15"
else if @wksta = "S15-8" goto "S15"
else if @wksta = "S15-9" goto "S15"
else if @wksta = "S15-10" goto "S15"
else if @wksta = "S15-11" goto "S15"
else if @wksta = "S15-12" goto "S15"
else if @wksta = "S15-13" goto "S15"
else if @wksta = "S15-14" goto "S15"
else if @wksta = "S15-Teacher" goto "S15" else goto "next11"

:next11
if @wksta = "S16-1" goto "S16"
else if @wksta = "S16-2" goto "S16"
else if @wksta = "S16-3" goto "S16"
else if @wksta = "S16-4" goto "S16"
else if @wksta = "S16-5" goto "S16"
else if @wksta = "S16-6" goto "S16"
else if @wksta = "S16-7" goto "S16"
else if @wksta = "S16-8" goto "S16"
else if @wksta = "S16-9" goto "S16"
else if @wksta = "S16-10" goto "S16"
else if @wksta = "S16-11" goto "S16"
else if @wksta = "S16-12" goto "S16"
else if @wksta = "S16-13" goto "S16"
else if @wksta = "S16-14" goto "S16"
else if @wksta = "S16-Teacher" goto "S16" else goto "next12"

:next12
if @wksta = "S6-1" goto "S6"
else if @wksta = "S6-2" goto "S6"
else if @wksta = "S6-3" goto "S6"
else if @wksta = "S6-4" goto "S6"
else if @wksta = "S6-5" goto "S6"
else if @wksta = "S6-6" goto "S6"
else if @wksta = "S6-7" goto "S6"
else if @wksta = "S6-8" goto "S6"
else if @wksta = "S6-9" goto "S6"
else if @wksta = "S6-10" goto "S6"
else if @wksta = "S6-11" goto "S6"
else if @wksta = "S6-12" goto "S6"
else if @wksta = "S6-13" goto "S6"
else if @wksta = "S6-14" goto "S6"
else if @wksta = "S6-15" goto "S6"
else if @wksta = "S6-16" goto "S6"
else if @wksta = "S6-Teacher" goto "S6" else goto "next13"

:next13
if @wksta = "S7-1" goto "S7"
else if @wksta = "S7-2" goto "S7"
else if @wksta = "S7-3" goto "S7"
else if @wksta = "S7-4" goto "S7"
else if @wksta = "S7-5" goto "S7"
else if @wksta = "S7-6" goto "S7"
else if @wksta = "S7-7" goto "S7"
else if @wksta = "S7-8" goto "S7"
else if @wksta = "S7-9" goto "S7"
else if @wksta = "S7-10" goto "S7"
else if @wksta = "S7-11" goto "S7"
else if @wksta = "S7-12" goto "S7"
else if @wksta = "S7-13" goto "S7"
else if @wksta = "S7-14" goto "S7"
else if @wksta = "S7-15" goto "S7"
else if @wksta = "S7-16" goto "S7"
else if @wksta = "S7-Teacher" goto "S7" else goto "next14"

:next14
if @wksta = "S19-1" goto "S19"
else if @wksta = "S19-2" goto "S19"
else if @wksta = "S19-3" goto "S19"
else if @wksta = "S19-4" goto "S19"
else if @wksta = "S19-5" goto "S19"
else if @wksta = "S19-6" goto "S19""
else if @wksta = "S19-7" goto "S19"
else if @wksta = "S19-8" goto "S19"
else if @wksta = "S19-9" goto "S19"
else if @wksta = "S19-10" goto "S19" else goto "next15"

:next15
if @wksta = "N9-1" goto "N9"
else if @wksta = "N9-2" goto "N9"
else if @wksta = "N9-3" goto "N9"
else if @wksta = "N9-4" goto "N9"
else if @wksta = "N9-5" goto "N9"
else if @wksta = "N9-6" goto "N9"
else if @wksta = "N9-7" goto "N9"
else if @wksta = "N9-8" goto "N9"
else if @wksta = "N9-9" goto "N9"
else if @wksta = "N9-10" goto "N9" else goto "next16"

:Next16
MESSAGEBOX ("PLEASE CHECK YOUR DEFAULT PRINTER BEFORE PRINTING! - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:library
;ADDPRINTERCONNECTION ("\\ALPHA\LIBRARY")
;SETDEFAULTPRINTER ("\\ALPHA\LIBRARY")
SETDEFAULTPRINTER ("LIBRARY-PHOTOCOPIER")
MESSAGEBOX ("Your Default Printer it set to LIBRARY-PHOTOCOPIER - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:lsf
MESSAGEBOX ("TEST MESSAGE 3","DEFAULT PRINTER",0,5)
ADDPRINTERCONNECTION ("\\ALPHA\LSF")
SETDEFAULTPRINTER ("\\ALPHA\LSF")
MESSAGEBOX ("Your Default Printer it set to LSF on ALPHA - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:maths
ADDPRINTERCONNECTION ("\\ALPHA\maths")
SETDEFAULTPRINTER ("\\ALPHA\maths")
MESSAGEBOX ("Your Default Printer it set to MATHS on ALPHA - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:history
ADDPRINTERCONNECTION ("\\ALPHA\history")
SETDEFAULTPRINTER ("\\ALPHA\history")
MESSAGEBOX ("Your Default Printer it set to HISTORY on ALPHA - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

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

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

:W9
ADDPRINTERCONNECTION ("\\ALPHA\W9")
SETDEFAULTPRINTER ("\\ALPHA\W9")
MESSAGEBOX ("Your Default Printer it set to W9 - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:W3
ADDPRINTERCONNECTION ("\\ALPHA\W3")
SETDEFAULTPRINTER ("\\ALPHA\W3")
MESSAGEBOX ("Your Default Printer it set to W3 - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

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

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

:science
ADDPRINTERCONNECTION ("\\ALPHA\science")
SETDEFAULTPRINTER ("\\ALPHA\science")
MESSAGEBOX ("Your Default Printer it set to SCIENCE (on ALPHA) - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:languages
ADDPRINTERCONNECTION ("\\ALPHA\LANGUAGES")
SETDEFAULTPRINTER ("\\ALPHA\LANGUAGES")
MESSAGEBOX ("Your Default Printer it set to LANGUAGES (on ALPHA) - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:s19
ADDPRINTERCONNECTION ("\\ALPHA\s19")
SETDEFAULTPRINTER ("\\ALPHA\s19")
MESSAGEBOX ("Your Default Printer it set to S19 (on ALPHA) - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:n9
ADDPRINTERCONNECTION ("\\ALPHA\N9")
SETDEFAULTPRINTER ("\\ALPHA\N9")
MESSAGEBOX ("Your Default Printer it set to N9 (on ALPHA) - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET
SETDEFAULTPRINTER ("LASERJET")
MESSAGEBOX ("!! Your Default Printer it set to HP LaserJet (Local) - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET1
ADDPRINTERCONNECTION ("\\LSF-1\LASERJET")
SETDEFAULTPRINTER ("\\LSF-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on LSF-1 - Please save your work regularly - goo goo ga joob","DEFAULT PRINTER",0,5)
goto "end"

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

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

:LASERJET4
ADDPRINTERCONNECTION ("\\HISTORY-1\LASERJET")
SETDEFAULTPRINTER ("\\HISTORY-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on HISTORY-1 - Please save your work regularly)","DEFAULT PRINTER",0,5)
goto "end"

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

:LASERJET6
ADDPRINTERCONNECTION ("\\SCIENCE-1\LASERJET")
SETDEFAULTPRINTER ("\\SCIENCE-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on SCIENCE-1) - Please save your work regularly.","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET7
ADDPRINTERCONNECTION ("\\LANGUAGES-2\LASERJET")
SETDEFAULTPRINTER ("\\LANGUAGES-2\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet (on LANGUAGES-2) - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET8
ADDPRINTERCONNECTION ("\\MATHS-1\LASERJET")
SETDEFAULTPRINTER ("\\MATHS-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on MATHS-1) - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET9
ADDPRINTERCONNECTION ("\\TAS-1\LASERJET")
SETDEFAULTPRINTER ("\\TAS-1\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on TAS-1 - Have a nice day.) - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

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

:LASERJET11
ADDPRINTERCONNECTION ("\\ALPHA\SOCSCI")
SETDEFAULTPRINTER ("\\ALPHA\SOCSCI")
MESSAGEBOX ("Your Default Printer it set to SOCSCI - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:LASERJET12
ADDPRINTERCONNECTION ("\\C7-3\LASERJET")
SETDEFAULTPRINTER ("\\C7-3\LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP LaserJet on C7-3) - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:LEXMARK1
SETDEFAULTPRINTER ("LEXMARK E321")
MESSAGEBOX ("Your Default Printer it set to Lexmark E321 (Local) - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:ART
ADDPRINTERCONNECTION ("\\ART-4\COLOR LASERJET")
ADDPRINTERCONNECTION ("\\ART-2\LEXMARK E321")
SETDEFAULTPRINTER ("LEXMARK E321")
MESSAGEBOX ("Your Default Printer it set to Lexmark E321 - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:COLORLASERJET
ADDPRINTERCONNECTION ("\\ART-6\HP Officejet Pro L7300")
SETDEFAULTPRINTER ("LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP COLOR LaserJet (Local) - Do not print without an Art teacher's permission","DEFAULT PRINTER",0,5)
goto "end"

:COLORLASERJET1
ADDPRINTERCONNECTION ("\\ART-6\HP Officejet Pro L7300")
SETDEFAULTPRINTER ("\\ART-4\COLOR LASERJET")
MESSAGEBOX ("Your Default Printer it set to HP COLOR LASERJET on ART-4 - Do not print without an Art teacher's permission","DEFAULT PRINTER",0,5)
goto "end"

:S15
ADDPRINTERCONNECTION ("\\alpha\s15")
SETDEFAULTPRINTER ("\\alpha\s15")
MESSAGEBOX ("Your Default Printer it set to S15 - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:S16
ADDPRINTERCONNECTION ("\\ALPHA\S16")
SETDEFAULTPRINTER ("\\ALPHA\S16")
MESSAGEBOX ("Your Default Printer it set to S16 - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:S6
ADDPRINTERCONNECTION ("\\ALPHA\S6")
SETDEFAULTPRINTER ("\\ALPHA\S6")
MESSAGEBOX ("Your Default Printer it set to S6 - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:S7
ADDPRINTERCONNECTION ("\\ALPHA\S7")
SETDEFAULTPRINTER ("\\ALPHA\S7")
MESSAGEBOX ("Your Default Printer it set to S7 - Please save your work regularly","DEFAULT PRINTER",0,5)
goto "end"

:end
endif



Edited by smileyguy (2008-06-07 01:20 AM)

Top
#188101 - 2008-06-07 01:22 AM Re: Script not working: dies in the right spot! [Re: smileyguy]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
What's with all the else if? Every IF needs an ENDIF!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#188102 - 2008-06-07 01:33 AM Re: Script not working: dies in the right spot! [Re: Les]
smileyguy Offline
Fresh Scripter

Registered: 2008-06-07
Posts: 6
It's been working for the last few years like this! I did make a couple of minor aditions recently and added the next4 and next5 sectons. I also just discovered one logon that died on the first line of that statement (if @Wksta = "W9-1" goto "w9"). The "W9" section (sory don't know correct term) is there and looks OK to me?
Top
#188103 - 2008-06-07 01:40 AM Re: Script not working: dies in the right spot! [Re: smileyguy]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Here is an example of how to clean this up, and make it much easier to read.

 Code:
select
  ;library
  case instr(@wksta,"lib-") or instr(@wksta,"mmc-") or instr(@wksta,"tsc-") or instr(@wksta,"libLoft-")
    $Printername="LIBRARY-PHOTOCOPIER"
    $SharedPrinter="\\ALPHA\LIBRARY"
  ;E5
  case instr(@wksta,"E5-")
    $Printername="E5"
    $SharedPrinter="\\ALPHA\E5"    
  ;next case
  case
  

endselect
$RC=ADDPRINTERCONNECTION($sharedPrinter)
$RC=SETDEFAULTPRINTER ($sharedprinter)
$RC=MESSAGEBOX ("Your Default Printer it set to " + $printername + " - Please save your work regularly","DEFAULT PRINTER",0,5)



Just copy/paste a case and make the appropriate changes.

Top
#188104 - 2008-06-07 01:47 AM Re: Script not working: dies in the right spot! [Re: Allen]
smileyguy Offline
Fresh Scripter

Registered: 2008-06-07
Posts: 6
Thanks - might look at at testing that this weekend. there is some redundant code in my old script. If it is just a local printer (ie.e., connected directly via USB, would it look like this?

$Printername="LIBRARY-PHOTOCOPIER"
$SharedPrinter="LIBRARY-PHOTOCOPIER"

Would still love it if I found out what was wrong with my old script:)

Top
#188105 - 2008-06-07 02:18 AM Re: Script not working: dies in the right spot! [Re: smileyguy]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
I think what Les and I are trying say is... you've got issues with the way your current script is, "fixing" it is probably not the right course of action. If you really want to fix it, then I suggest doing as Les's suggested and putting a corresponding endif with all those if's. Another option is to search for Sanity() here on the board. You can run your script through that, and it will help you find errors.
Top
#188106 - 2008-06-07 03:48 AM Re: Script not working: dies in the right spot! [Re: Allen]
smileyguy Offline
Fresh Scripter

Registered: 2008-06-07
Posts: 6
Thanks very much. i think I have enough to work from here. Don't know any scripting but it looks logical enough. i don't know why my old script just stopped working though.

A couple of quick questions (yes you can tell I am a complete novice!).

1: What would the string look like for a local printer (not network shared). here is a beeter example than my last question;;

$Printername="LASERJET"
$SharedPrinter="LASERJET"

2: with this line "case instr(@wksta,"lib-") or instr(@wksta,"mmc-") or instr(@wksta,"tsc-") or instr(@wksta,"libLoft-")"
, it wuoldn't matter if I split it onto separate lines would it? So it would look like this: (just makes it a little easier to read for not real geeks like me:))

case instr(@wksta,"lib-")
or instr(@wksta,"mmc-")
or instr(@wksta,"tsc-")
or instr(@wksta,"libLoft-")

Top
#188107 - 2008-06-07 05:04 AM Re: Script not working: dies in the right spot! [Re: smileyguy]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
A. This code is broken - badly - as has been pointed out by Les and Allen. The time you take to fix it could be spent creating managable code.

B. Hard coding site & computer data into your scripts is a bad idea. Every time a printer, server, or location changes, you need to modify your script, and every time you edit a script, you introduce the possibility for errors.

Please take a look at this post, which was discussed just this week and illustrates a method for mapping printers from a configuration file. This can reduce your script to about 2-dozen lines. The example is actually shorter than that, but could use some error checking, and you'll need to tie it into your processing logic. Still, much simpler code and less prone to failure when your environment changes.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#188176 - 2008-06-12 09:21 AM Re: Script not working: dies in the right spot! [Re: Glenn Barnas]
smileyguy Offline
Fresh Scripter

Registered: 2008-06-07
Posts: 6
Thanks guys. Allen's structure is working great. I can work off that well enough to rewrite for my school (I am a teacher here!)

Now this is not an argument, just a dummy question or two:

1) Why is my old script broken? It was working fine with that structure for years until I probably stuffed up the syntax somewhere. What happens if you don't put endifs after each if statement. The structure has been the same for years.

2) Does it matter if I put line breaks anywhere in the new script? I am sure this sounds too obvious and stupid but would love it if someone had the time to answer:)

Cheers all:)

Top
#188181 - 2008-06-12 11:09 AM Re: Script not working: dies in the right spot! [Re: smileyguy]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Quote:
Does it matter if I put line breaks anywhere in the new script?


KiXtart is format free (mostly) so you can break it up any way you wish. Wherever there is a delimiter (not just a space) you can put new lines,spaces or tabs - as many as you want.

You can also go to the other extreme and put your entire script on a single line (as long as there are no comments in it!).

There are a couple of places that you don't want to put newlines because it would break the script, but as they'd badly affect the readability of the script you would naturally avoid them anyway.

Top
#188184 - 2008-06-12 12:43 PM Re: Script not working: dies in the right spot! [Re: Richard H.]
smileyguy Offline
Fresh Scripter

Registered: 2008-06-07
Posts: 6
Thanks:)

Working on the new scrip - it's almost done.

I reduced my old script to just one computer/workstation and a dew printers, and I got an error "enidf with no if". Trying to figure out what that means. Just doing this to learn really.

Anyway - the new script seems to be working nicely thanks:)

Top
#188188 - 2008-06-12 01:36 PM Re: Script not working: dies in the right spot! [Re: smileyguy]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
EndIf with no If means exactly what it says. Kix sees an EndIf but no corresponding If. This could be because the If is missing or there is a missing quote or a missing ). This could be a pain to figure out especially when your script grows bigger and bigger and bigger and .......
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#188195 - 2008-06-12 04:14 PM Re: Script not working: dies in the right spot! [Re: Mart]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
"especially when your script grows bigger and bigger and bigger and ....... "

This is precisely why I recommended that you don't code site/user/computer logic into your script. The bigger the script, the harder to maintain, and the more opportunities you have for errors.

Using an INI file, you could create something like this:
 Code:
[DECISION-01]
Printers=\\server1\printer1;\\server1\printer2
Default=\\server1\printer2

Now all you do is create a section like that for each "decision point". A "decision point can be a computer, group, OU, site name, or subnet.

Once you have this INI configured, you have some simple code (in this example, a per-computer decision):
 Code:
$SectionID = @WKSTA
$Printers = ReadProfileString('.\printermaps.ini', $SectionID, 'Printers')
For Each $Printer in Split($Printers, ';')
  $ = AddPrinterConnection($Printer)
Next
SetDefaultPrinter(ReadProfileString('.\printermaps.ini', $SectionID, 'Default'))

Now you only update the ini file, not your code, as printers or decision-points change, and your code is short, sweet, and simple.

The code above can be easily adapted to any decision-point by replacing the $SectionID= line with the proper logic. There are UDFs to identify subnets, OU and group membership, and my web site has a UDF that accepts a network IP address, and returns a value from a config file based on the subnet your computer is in. With it, you could create a table of site-names by subnet, returning the SiteName directly to the $SectionID value.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#188208 - 2008-06-13 12:47 AM Re: Script not working: dies in the right spot! [Re: Glenn Barnas]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
ENDIF without IF could also be a spaghetti issue of jumping (GOTO) the middle of a loop.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#188214 - 2008-06-13 04:52 PM Re: Script not working: dies in the right spot! [Re: Les]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
wow... WOW.. Did you get it working ? *_*
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

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 883 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.066 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

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