Page 1 of 1 1
Topic Options
#162878 - 2006-06-05 03:05 PM Need help in debugging script
titanax101 Offline
Fresh Scripter

Registered: 2006-06-05
Posts: 5
Hi,

I'm a noob...this is my 1st kixtart script. It's very simple, just drive & printer mappings...its a series of IF & ENDIF statements, but the script doens't detect any of the IF statements AFTER THE 9TH IF.

Is there some limitation on the no. of IFs I can have? I dun really want to use InGroup as there are subsets.

I'm running W2K3 server with XP clients. These are the files in my NETLOGON:
KIX32.EXE
WKIX32.EXE
KIXTART.KIX

Code:

CLS
SETTIME "\\domaincontroller"
USE * /delete
USE H: "\\fileserver\%username%$"
USE P: "\\fileserver\PUBLIC"
USE U: "\\fileserver\SUPPORT"

IF @UserId = "fred"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserverfileserver\dc286")
SetDefaultPrinter("\\fileserver\dc286")
ENDIF

IF @UserId = "north_ops"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserverfileserver\dc286")
SetDefaultPrinter("\\fileserver\dc286")
ENDIF

IF @UserId = "terry"
USE K: "\\fileserver\NORTH"
USE L: "\\fileserver\DELIVERY"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserver\dc286")
SetDefaultPrinter("\\fileserver\dc286")
ENDIF

IF @UserId = "yuri"
USE K: "\\fileserver\northSGDATA"
USE L: "\\fileserver\DELIVERY"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserverfileserver\dc286")
SetDefaultPrinter("\\fileserver\dc286")
ENDIF

IF @UserId = "wiriam"
USE K: "\\fileserver\NORTH"
USE L: "\\fileserver\DELIVERY"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserver\dcc400_black")
SetDefaultPrinter("\\fileserver\dcc400_black")
AddPrinterConnection("\\fileserverfileserver\dc286")
ENDIF

IF @UserId = "ted"
USE Y: "\\fileserver\HELPDESK"
USE T: "\\fileserver\NORTH"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserver\dcc400_color")
SetDefaultPrinter("\\fileserver\dcc400_color")
ENDIF

IF @UserId = "michael"
USE M: "\\fileserver\ADMIN"
USE L: "\\fileserver\DELIVERY"
USE K: "\\fileserver\NORTH"
USE O: "\\fileserver\OPERATIONS"
USE S: "\\fileserver\SALES"
USE Y: "\\fileserver\HELPDESK"
AddPrinterConnection("\\fileserver\dcc400_color")
SetDefaultPrinter("\\fileserver\dcc400_color")
ENDIF

IF @UserId = "maggir"
USE M: "\\fileserver\ADMIN"
USE L: "\\fileserver\DELIVERY"
USE K: "\\fileserver\NORTH"
USE O: "\\fileserver\OPERATIONS"
USE S: "\\fileserver\SALES"
AddPrinterConnection("\\fileserver\dc286")
SetDefaultPrinter("\\fileserver\dc286")
AddPrinterConnection("\\fileserver\dcc400_color")
ENDIF

IF @UserId = "martin"
USE K: "\\fileserver\NORTH"
USE L: "\\fileserver\DELIVERY"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserver\dcc400_black")
SetDefaultPrinter("\\fileserver\dcc400_black")
AddPrinterConnection("\\fileserver\dc286")
ENDIF

;script doesn't detect after the 9th IF

IF @UserId = "alyson"
USE K: "\\fileserver\NORTH"
AddPrinterConnection("\\fileserver\dcc400_color")
SetDefaultPrinter("\\fileserver\dcc400_color")
ENDIF


{Edit: Allen - added code tags}

Top
#162879 - 2006-06-05 03:21 PM Re: Need help in debugging script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Since @UserID is exclusive, you should be using a Select Case construct instead of all those IFs.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162880 - 2006-06-05 03:24 PM Re: Need help in debugging script
titanax101 Offline
Fresh Scripter

Registered: 2006-06-05
Posts: 5
OK..thankx for the prompt reply...but I have no idea what that means!
Top
#162881 - 2006-06-05 04:04 PM Re: Need help in debugging script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... of all those IFs, there can only be one true result, so rather than continue what is sure to be false after the one true IF, you should use Select Case instead.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162882 - 2006-06-05 04:32 PM Re: Need help in debugging script
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Les means to do something along these lines
Code:

Select
Case @UserId = "fred"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserverfileserver\dc286")
SetDefaultPrinter("\\fileserver\dc286")

Case @UserId = "north_ops"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserverfileserver\dc286")
SetDefaultPrinter("\\fileserver\dc286")


Case @UserId = "terry"
USE K: "\\fileserver\NORTH"
USE L: "\\fileserver\DELIVERY"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserver\dc286")
SetDefaultPrinter("\\fileserver\dc286")


Case @UserId = "yuri"
USE K: "\\fileserver\northSGDATA"
USE L: "\\fileserver\DELIVERY"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserverfileserver\dc286")
SetDefaultPrinter("\\fileserver\dc286")


Case @UserId = "wiriam"
USE K: "\\fileserver\NORTH"
USE L: "\\fileserver\DELIVERY"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserver\dcc400_black")
SetDefaultPrinter("\\fileserver\dcc400_black")
AddPrinterConnection("\\fileserverfileserver\dc286")


Case @UserId = "ted"
USE Y: "\\fileserver\HELPDESK"
USE T: "\\fileserver\NORTH"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserver\dcc400_color")
SetDefaultPrinter("\\fileserver\dcc400_color")


Case @UserId = "michael"
USE M: "\\fileserver\ADMIN"
USE L: "\\fileserver\DELIVERY"
USE K: "\\fileserver\NORTH"
USE O: "\\fileserver\OPERATIONS"
USE S: "\\fileserver\SALES"
USE Y: "\\fileserver\HELPDESK"
AddPrinterConnection("\\fileserver\dcc400_color")
SetDefaultPrinter("\\fileserver\dcc400_color")


Case @UserId = "maggir"
USE M: "\\fileserver\ADMIN"
USE L: "\\fileserver\DELIVERY"
USE K: "\\fileserver\NORTH"
USE O: "\\fileserver\OPERATIONS"
USE S: "\\fileserver\SALES"
AddPrinterConnection("\\fileserver\dc286")
SetDefaultPrinter("\\fileserver\dc286")
AddPrinterConnection("\\fileserver\dcc400_color")


Case @UserId = "martin"
USE K: "\\fileserver\NORTH"
USE L: "\\fileserver\DELIVERY"
USE O: "\\fileserver\OPERATIONS"
AddPrinterConnection("\\fileserver\dcc400_black")
SetDefaultPrinter("\\fileserver\dcc400_black")
AddPrinterConnection("\\fileserver\dc286")


Case @UserId = "alyson"
USE K: "\\fileserver\NORTH"
AddPrinterConnection("\\fileserver\dcc400_color")
SetDefaultPrinter("\\fileserver\dcc400_color")

EndSelect

_________________________
Today is the tomorrow you worried about yesterday.

Top
#162883 - 2006-06-05 04:39 PM Re: Need help in debugging script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Ja, except it is prudent to include a Case 1 as the last case.

If there are a large number of users, it would be better to switch over to using INI files. If every user had their own INI, you could manage things by creating/editing the INI files named after the @UserID and not have to constantly edit the script. It is too easy to fubar the script with a misplaced quote of EndIf, etc.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162884 - 2006-06-05 04:44 PM Re: Need help in debugging script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Is there any reason why your not using Security Groups and InGroup for this stuff ? Much better long term solution imho.
Top
#162885 - 2006-06-05 04:55 PM Re: Need help in debugging script
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
And to further clean up your script
Code:

CLS
SETTIME "\\domaincontroller"
USE * /delete
USE H: "\\fileserver\%username%$"
USE P: "\\fileserver\PUBLIC"
USE U: "\\fileserver\SUPPORT"

If @UserId <> "alyson"
Use O: "\\fileserver\OPERATIONS"
EndIf

If NOT @UserId = "ted" OR NOT @UserId = "michael" OR NOT @UserId = "alyson"
AddPrinterConnection("\\fileserverfileserver\dc286")
EndIf

If NOT @UserId = "fred" OR NOT @UserID = "north_ops" OR NOT @UserId = "yuri"
USE K: "\\fileserver\NORTH"
EndIf

Select
Case @UserId = "fred"
SetDefaultPrinter("\\fileserver\dc286")

Case @UserId = "north_ops"
SetDefaultPrinter("\\fileserver\dc286")

Case @UserId = "terry"
USE L: "\\fileserver\DELIVERY"
SetDefaultPrinter("\\fileserver\dc286")

Case @UserId = "yuri"
USE L: "\\fileserver\DELIVERY"
SetDefaultPrinter("\\fileserver\dc286")

Case @UserId = "wiriam"
USE L: "\\fileserver\DELIVERY"
AddPrinterConnection("\\fileserver\dcc400_black")
SetDefaultPrinter("\\fileserver\dcc400_black")

Case @UserId = "ted"
USE Y: "\\fileserver\HELPDESK"
USE T: "\\fileserver\NORTH"
AddPrinterConnection("\\fileserver\dcc400_color")
SetDefaultPrinter("\\fileserver\dcc400_color")

Case @UserId = "michael"
USE M: "\\fileserver\ADMIN"
USE L: "\\fileserver\DELIVERY"
USE S: "\\fileserver\SALES"
USE Y: "\\fileserver\HELPDESK"
AddPrinterConnection("\\fileserver\dcc400_color")
SetDefaultPrinter("\\fileserver\dcc400_color")

Case @UserId = "maggir"
USE M: "\\fileserver\ADMIN"
USE L: "\\fileserver\DELIVERY"
USE S: "\\fileserver\SALES"
AddPrinterConnection("\\fileserver\dcc400_color")
SetDefaultPrinter("\\fileserver\dc286")

Case @UserId = "martin"
USE L: "\\fileserver\DELIVERY"
AddPrinterConnection("\\fileserver\dcc400_black")
SetDefaultPrinter("\\fileserver\dcc400_black")
AddPrinterConnection("\\fileserver\dc286")


Case @UserId = "alyson"
AddPrinterConnection("\\fileserver\dcc400_color")
SetDefaultPrinter("\\fileserver\dcc400_color")
Case 1

EndSelect


_________________________
Today is the tomorrow you worried about yesterday.

Top
#162886 - 2006-06-05 05:02 PM Re: Need help in debugging script
titanax101 Offline
Fresh Scripter

Registered: 2006-06-05
Posts: 5
wow...thankx a lot guys...thats so much help...& now to answer why I amo not using the Ingroup, it goes all qirky..I get users with drives they are not supposed to get..its bizarre
Top
#162887 - 2006-06-05 05:07 PM Re: Need help in debugging script
titanax101 Offline
Fresh Scripter

Registered: 2006-06-05
Posts: 5
Quote:

If there are a large number of users, it would be better to switch over to using INI files. If every user had their own INI, you could manage things by creating/editing the INI files named after the @UserID and not have to constantly edit the script. It is too easy to fubar the script with a misplaced quote of EndIf, etc.




les, could you gimme a simple illustration?

Top
#162888 - 2006-06-05 06:30 PM Re: Need help in debugging script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Make sure to clean-up your console output by "capturing" return values, like this:

$RC = AddPrinterConnection("\\fileserver\dcc400_color")
$RC = SetDefaultPrinter("\\fileserver\dcc400_color")

Top
#162889 - 2006-06-05 06:45 PM Re: Need help in debugging script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

les, could you gimme a simple illustration?



Unfortunately, it is not covered in KiXing 101. You'll need to sign up for the advanced class KiXing 301. You can take a look at code http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=82907 but don't stare at it for too long.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162890 - 2006-06-06 08:45 AM Re: Need help in debugging script
titanax101 Offline
Fresh Scripter

Registered: 2006-06-05
Posts: 5
good one les...couldn't help staring tho...had a slight epilepsy episode even!!
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 1003 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.065 seconds in which 0.026 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