Page 1 of 1 1
Topic Options
#176894 - 2007-06-11 07:40 PM Case statement failure in some profiles
Nick_at_PT Offline
Fresh Scripter

Registered: 2007-06-11
Posts: 13
Loc: Dallas, TX, US
I have an odd issue with a script I just implemented in one of my sites.

The site was using KIX before, but I changed them to a new, more complex KIX script.

Some users are working fine with the new script, but others do not. The users that do not work, get the mappings that are defined until they get to a Select Case statement.

If I log these users onto another computer, they are fine. If I log into their computer, it is fine. This seems to be limited to the original user profile on their specific computer. I have multiple instances of this and have rebuilt one user profile and had the issue go away.

I am expected to roll out this script company wide and would like to find the cause of the issue instead of rebuilding everyone's profile.

The issue affected both their desktop profiles and Citrix profiles, but deleting either and creating a new profile resolves the issue.

Any help is greatly appreciated.

I have mappings before this command in the script that work. This segment is where the failure seems to be.

Script sample:
CLS
;Determine Script Group Membership and process the proper subroutine
Select

Case InGroup("BAWHScript")
Gosub "BAWH"
Case InGroup("BahiaScript")
Gosub "BMBR"
Case InGroup("BMBRScript")
Gosub "BMBR"
Case InGroup("BRGSScript")
Gosub "BRGS"
Case InGroup("BRRCScript")
Gosub "BRRC"
Case InGroup("BVPSScript")
Gosub "BVPS"
Case InGroup("CMKWScript")
Gosub "CMKW"
EndSelect


Edited by Nick_at_LXR (2007-06-11 07:42 PM)
Edit Reason: Added script segment

Top
#176895 - 2007-06-11 09:06 PM Re: Case statement failure in some profiles [Re: Nick_at_PT]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Could be a lot of issues, you've not provided near enough information for us to help you much though.

What version of KiXtart?
What Network NT/AD?
What clients 9x/NT/WK2/XP/Vista?
Does KiX run from NETLOGON or from local system?

I would highly recommend against using the GOSUB as there are much better coding styles to replace it.

If the code is not too big please post the full script here so that we can assist you with it. You can remove any proprietary information before posting. Make sure you use the CODE TAGS when posting to keep the formatting of the script though.

Top
#176897 - 2007-06-11 09:27 PM Re: Case statement failure in some profiles [Re: NTDOC]
Nick_at_PT Offline
Fresh Scripter

Registered: 2007-06-11
Posts: 13
Loc: Dallas, TX, US
Sorry.

KiXtart 4.50.0.0
Windows 2003 Active Directory
Windows XP clients
Kix32.exe is hosted in \\domain\netlogon

The script is huge. 34kb. As you can see by the segment posted above, I am parsing group membership to define which segments of the script to run.

CTX is a variable set earlier in the script to define if script is running in a terminal session. This is the section of code that the previous GoSub refers to:

 Code:
:CMKW
	? "Executing Logon Script"
	Sleep 2

	;Setting variable for Shared/Public drive
	$K="\\server2\share3"

	If $CTX="1"
		If InGroup("Group2")
			Use K: $K
		EndIf

		Return
	EndIf

	If InGroup("Group2")
		Use K: $K
	EndIf

	If InGroup("Group1")
		Use O: "\\server1\share1"
		Use X: "\\server1\share2"
	EndIf

Return


Edited by Nick_at_LXR (2007-06-11 09:48 PM)
Edit Reason: added code

Top
#176900 - 2007-06-12 12:31 AM Re: Case statement failure in some profiles [Re: Nick_at_PT]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
I sent you a private message Nick. You might be able to post your script as an attachment in a zip file for review.

The use of GoSub, GoTo, and their labels can be quite a pain to track and manage especially as a script gets larger. Rewriting the script to eliminate its use would be the preferred method, but we can take a look at it's current implementation if the script is posted.

Top
#176907 - 2007-06-12 09:22 AM Re: Case statement failure in some profiles [Re: NTDOC]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If removing the profile is fixing the problem then a good candidate for the cause is the KiXtart group membership cache - have you been changing group names?

Add the "-f" flush parameter when you call the script to force the cache to refresh. Use todays date to avoid unnecessary refreshes.
 Code:
kix32.exe -f 2007/06/12 mylogonscript.kix


Try it on a login that you know is failing.

If that doesn't help, reduce your script to a few lines that demonstrate the problem and add some debugging output.

Top
#176908 - 2007-06-12 09:42 AM Re: Case statement failure in some profiles [Re: Richard H.]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Remove the "Return" command \:\)
Top
#176909 - 2007-06-12 10:06 AM Re: Case statement failure in some profiles [Re: Arend_]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: apronk
Remove the "Return" command \:\)

Why would you want to remove the "Return" from a subroutine?

Top
#176922 - 2007-06-12 01:16 PM Re: Case statement failure in some profiles [Re: Richard H.]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
 Originally Posted By: Richard H.
 Originally Posted By: apronk
Remove the "Return" command \:\)

Why would you want to remove the "Return" from a subroutine?


Because as far as I can see from the scriplet he postet, the first return statement makes the script not process the next if-else statement, wich I think is needed to process.
Besides that I hate Return commands \:\)

Top
#176923 - 2007-06-12 01:37 PM Re: Case statement failure in some profiles [Re: Arend_]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: apronk
Because as far as I can see from the scriplet he postet, the first return statement makes the script not process the next if-else statement, wich I think is needed to process.


I suspect that the return in the IF construct is actually to halt processing of the subroutine if it is a CTX (Citrix) login - in which case it is correct if a bit poorly structured.

A better (and clearer) flow would be:
 Code:
:CMKW
	;Setting variable for Shared/Public drive
	$K="\\server2\share3"
 
	If InGroup("Group2")
		Use K: $K
	EndIf
 
	If $CTX<>"1" AND InGroup("Group1")
		Use O: "\\server1\share1"
		Use X: "\\server1\share2"
	EndIf

Return


There are a number of variations that would work just as well.

 Quote:
Besides that I hate Return commands \:\)

No argument here, but simply removing it would mean that the script would not function correctly.

Top
#176924 - 2007-06-12 02:39 PM Re: Case statement failure in some profiles [Re: Richard H.]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
As before, I completely agree with you \:\)

Top
#176925 - 2007-06-12 02:51 PM Re: Case statement failure in some profiles [Re: Arend_]
Nick_at_PT Offline
Fresh Scripter

Registered: 2007-06-11
Posts: 13
Loc: Dallas, TX, US
I will try the flush. I can't reduce the script to this one site because other sites are already using it. Any change to that script is a production change.

Any way I can do a flush without actually running the script? I'd like to see if I can correct the issue without forcing a production change.

Also, is there any damage to forcing Kix to refresh cache every time it loads?

Top
#176926 - 2007-06-12 03:04 PM Re: Case statement failure in some profiles [Re: Nick_at_PT]
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
If you can not change this script because others use it in production, then duplicate it and set the user having the problem to execute it. This way you can make edits to troubleshoot the problem.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#176927 - 2007-06-12 03:05 PM Re: Case statement failure in some profiles [Re: Nick_at_PT]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Quote:
I can't reduce the script to this one site because other sites are already using it. Any change to that script is a production change


Ok, but you can run the script stand-alone on a PC at the site once it the user has logged in, can't you? In which case you could run a cut down version for debugging or testing. The same error should occur at both login and once the login has completed.

 Quote:
Any way I can do a flush without actually running the script? I'd like to see if I can correct the issue without forcing a production change


Sure - the cache is just a registry key. Delete it from the profile of the user that is having the problem, and KiXtart will recreate it.

The key is: HKEY_CURRENT_USER\Software\KiXtart\TokenCache

 Quote:
Also, is there any damage to forcing Kix to refresh cache every time it loads?


Yes - you can either use the "-f" flag without a date, or you can delete the registry key when your script starts.

The overhead with deleting the cache is that KiXtart has to enumerate the group structure each time, which may impact logon times depending on the complexity of your structure, and the speed of the connection between the client and the authenticating server.

Top
#176928 - 2007-06-12 03:32 PM Re: Case statement failure in some profiles [Re: Richard H.]
Nick_at_PT Offline
Fresh Scripter

Registered: 2007-06-11
Posts: 13
Loc: Dallas, TX, US
Brilliant!!!!

Looks like a tokencache issue. Deleting the registry key allowed the user to map the drive.

Thank you.

I have to resolve this on the other workstations for now, but would love to get some feedback on the other suggestions made for my script.

Thanks again.

Top
#176937 - 2007-06-12 09:13 PM Re: Case statement failure in some profiles [Re: Nick_at_PT]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
 Originally Posted By: Nick_at_LXR

would love to get some feedback on the other suggestions made for my script.


Well you implied you could not (or did not want to) make changes to the production script so not sure what good it would do us to offer suggestions on changes, but here are some none the less.

1. Update to 4.53 (many, many fixes since 4.50)
2. Run the script silently
3. Eliminate GoTo, GoSub, Label type coding style
4. Review usage of Select (it is exclusive, not inclusive - first entry wins and code jumps out of Select statement and on to next code)
5. Implement usage of published UDFs for IP lookups, and Drive Mappings.
6. Check for printer installation instead of re-installing every logon

Hopefully these should be enough to get you started.

Cheers...

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
1 registered (Allen) and 1607 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.072 seconds in which 0.028 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