Page 1 of 3 123>
Topic Options
#162985 - 2006-06-07 12:56 AM KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
I recently implemented KiXtart 2010 into my environment to replace all my old .bat login scripts. I borrowed fairly heavily from the adminscripteditor.com script library Domain Login Script. Now, I am seeing sporadic cases where workstations don't get mapped drives, and other cases where the drives map but all disappear about 20 minutes later. I have not been able to determine yet if the two instances are related. On workstations where drives don't get mapped, manually running the KIX executable seems to work (I will be investigating the XP wait on network setting). The script is fairly basic, thus (I have abridged redundant sections and sanitized it a bit):

Code:

; *** Login Script for all domain users ***

$ErrorFile = "\\recordingserver\Errorlogs\@WKSTA_ERR.TXT"

CLS

; Everyone gets the G drive


$Path = "\\nas\apps"
$Drive = "G"
Gosub Map


; HR is the only group that doesn't get the J drive

If NOT INGROUP("HR")
$Path = "\\server2\Drive"
$Drive = "J"
Gosub Map
EndIf

; Begin mapping drives for the individual groups


If INGROUP("Group1")
$Path = "\\callserver1\ccrecordings$"
$Drive = "P"
Gosub Map
$Path = "\\callserver2\ccrecordings$"
$Drive = "Q"
Gosub Map
$Path = "\\callserver3\ccrecordings$"
$Drive = "R"
Gosub Map
EndIf

IF INGROUP("Legal")
$Path = "\\nas\legal"
$Drive = "R"
Gosub Map
EndIf

IF INGROUP("IT")
$Path = "\\remotenas\software"
$Drive = "R"
Gosub Map
$Path = "\\ITServer\Drive"
$Drive = "W"
Gosub Map
$Path = "\\ITServer\install$"
$Drive = "Y"
Gosub Map
EndIf

IF INGROUP("HR")
$Path = "\\nas\hr"
$Drive = "U"
Gosub Map
EndIf

IF INGROUP("scangroup")
$Path = "\\nas\scan"
$Drive = "S"
Gosub Map
EndIf

Exit


:Map
Use $Drive+":" /Del /PERSISTENT
Use $Drive+":" $Path
If @error = 0
? " "+ $Drive+":" + $Path + " MAPPED"
Else
Color y+/n
? " MAP "+ $Drive+":" + $Path + " FAILED !"
Color w/n
Gosub ErrLog
EndIf
Return


:ERRLOG
If Open (1, $ErrorFile, 5) = 0
WriteLine(1, $Drive + ": " + $Path + " not mapped | @ERROR | @DATE | @TIME | @USERID | @WKSTA | @FULLNAME" + Chr(13) + Chr(10))
Else
? "Error openning 'ErrorLogs'"
EndIf
Close (1)
Return




I am seeing error files from some workstations, but in all cases the @ERROR code is 0. Any thoughts/input would be helpful. G and J drives seem to be the most problematical, but then nearly everyone in the domain gets them so they are almost certainly over-represented.


Edited by Allen (2006-06-07 01:32 AM)

Top
#162986 - 2006-06-07 10:05 AM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
Mart Moderator Online   content
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4642
Loc: The Netherlands
Modified tour script a bit hope you don’t mind.
I removed the GoSub stuff. GoSub (and GoTo) should not be used in best practice because they make spaghetti code that is almost impossible to read and the flow of the script gets hard to follow.


Untested but the script below should work.
It first deletes the drives before mapping them because users can delete a drive mapping and map some other drive. It uses the /persistent option to also delete the drive is it has been mapped persistent. If the mapping of a drive failed it writes a line to the log file with error codes and workstation name.
Code:

; *** Login Script for all domain users ***

$rc = Open (1, "\\recordingserver\Errorlogs\" + @WKSTA + "_ERR.TXT", 5)

CLS

; Everyone gets the G drive
Use g: /delete /persistent
Use g: "\\nas\apps"
If @ERROR
$rc = WriteLine (1, "Everyone. " + @WKSTA + " has problems mapping the G drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf

; HR is the only group that doesn't get the J drive
If NOT InGroup("HR")
Use j: /delete /persistent
Use j: "\\server2\Drive"
If @ERROR
$rc = WriteLine (1, "All users but HR. " + @WKSTA + " has problems mapping the J drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf
EndIf

; Begin mapping drives for the individual groups
If InGroup("Group1")
Use p: /delete /persistent
Use q: /delete /persistent
Use r: /delete /persistent
Use p: "\\callserver1\ccrecordings$"
If @ERROR
$rc = WriteLine (1, "Group1. " + @WKSTA + " has problems mapping the P drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf
Use q: "\\callserver2\ccrecordings$"
If @ERROR
$rc = WriteLine (1, "Group1. " + @WKSTA + " has problems mapping the Q drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf
Use r: "\\callserver3\ccrecordings$"
If @ERROR
$rc = WriteLine (1, "Group1. " + @WKSTA + " has problems mapping the R drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf
EndIf

If InGroup("Legal")
Use r: /delete /persistent
Use r: "\\nas\legal"
If @ERROR
$rc = WriteLine (1, "Legal. " + @WKSTA + " has problems mapping the R drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf
EndIf

If InGroup("IT")
Use r: /delete /persistent
Use w: /delete /persistent
Use y: /delete /persistent
Use r: "\\remotenas\software"
If @ERROR
$rc = WriteLine (1, "IT group. " + @WKSTA + " has problems mapping the R drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf
Use w: "\\ITServer\Drive"
If @ERROR
$rc = WriteLine (1, "IT group. " + @WKSTA + " has problems mapping the W drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf
Use y: "\\ITServer\install$"
If @ERROR
$rc = WriteLine (1, "IT group. " + @WKSTA + " has problems mapping the Y drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf
EndIf

If InGroup("HR")
Use u: /delete /persistent
Use u: "\\nas\hr"
If @ERROR
$rc = WriteLine (1, "HR group. " + @WKSTA + " has problems mapping the U drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf
EndIf

If InGroup("scangroup")
Use s: /delete /persistent
Use s: "\\nas\scan"
If @ERROR
$rc = WriteLine (1, "Scangroup. " + @WKSTA + " has problems mapping the U drive." + @CRLF)
$rc = WriteLine (1, @ERROR + " " + @SERROR + @CRLF)
EndIf
EndIf

$rc = Close (1)

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#162987 - 2006-06-07 02:38 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
I appreciate the input on Gosub. I actually originally had the script set as you do, to map the drives directly in each section, and was still seeing the problems with some workstations not getting their mapped drives (couldn't tell if they were running the script or not). I switched to this one to see if a change to the mapping procedure made any difference (and it had the error logging built in). I now get error log files from some machines, but not others. I was a little curious about your comment regarding spaghetti code. What is the difference between a Gosub and a function() call? Aren't they essentially the same as far as the flow of the code in the script?

I forgot to mention in the original post: the desktop environment is all XP Pro (some sp1, mostly sp2), and the backend is all 2003 server. AD is running in native 2003 mode, and replication is working fine between all 3 domain controllers.

Top
#162988 - 2006-06-07 02:54 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
I tested your script. The IF @ERROR sections seem to simply re-set the $rc variable to the new value you have (Writeline etc etc). All my error files were coming in empty. They'd get created, but there was no text in them. I rewrote the script again, using the direct mappings as you have them, but calling the original ERRLOG subroutine which I know works.
Top
#162989 - 2006-06-07 03:01 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
Mart Moderator Online   content
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4642
Loc: The Netherlands
GoSub and GoTo both jump backwards and forwards in the script so the flow of the script is difficult to follow just like a plate of spaghetti Functions are build-in in the executable or (when it is a UDF) is placed between Function and EndFunction so it gets read into memory before anything else in the script gets executed. I prefer putting any UDF’s into a separate file and call them at the beginning of the script that uses them.


First I would disable XP fast logon optimization because it sucks. If this doe not solve the problem then I would take one machine that has problems and put it in a so called quarantine environment and run some tests to see where things get screwed up. Does it also happen when other users logon to the system that does not map properly is it just one user having trouble? What happens if you replace the kix32.exe and/or wkix32.exe with fresh copies? Are you sure you are running the latest released (not beta) version of kix?
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#162990 - 2006-06-07 03:12 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
Mart Moderator Online   content
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4642
Loc: The Netherlands
Quote:


I tested your script. The IF @ERROR sections seem to simply re-set the $rc variable to the new value you have (Writeline etc etc).
....





Nope the $rc gets set by WriteLine. It will be 0 if writeline works.

Quote:


....
All my error files were coming in empty. They'd get created, but there was no text in them. I rewrote the script again, using the direct mappings as you have them, but calling the original ERRLOG subroutine which I know works.





An error file gets created by the 5 option when I open the file. 5 is the sum of 1 create if file does not exists) and 4 open for writing. There is a bug in my code because writeline will also set @error Sorry for that.
If you put these lines just after each use command it should show something on the screen. Can you tell us what you see on the screen? All writeline lines can be removed.

Code:

?@error
?@serror
Sleep 2

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#162991 - 2006-06-07 03:48 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
When I put those lines in, I see that all my operations complete (but then, I never had any problem). Is there an alternative to the WriteLine command that will not change the @ERROR so I can see why drives aren't mapping?
Top
#162992 - 2006-06-07 03:59 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
Mart Moderator Online   content
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4642
Loc: The Netherlands
RedirectOutput might be an option.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#162993 - 2006-06-07 05:27 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
I'll look at that. In the meantime, any thoughts on why drives might map successfully, but disappear (as in no longer visible in "My Computer") 10-20 minutes later?
Top
#162994 - 2006-06-07 05:39 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
I have a test script setup now, and edited the script to deliberately fail on mapping a drive (wrong server name). I get a return error code of 0, even though there is no way the drive can map (and indeed the drive doesn't map). Any thoughts?
Top
#162995 - 2006-06-07 05:52 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
There is a flaw in your logic. You use WriteLine() to write the error but WriteLine() will change @Error. You need to capture @Error to a var when it still holds the result from USE.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162996 - 2006-06-07 05:56 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Disappearing drives are the function of the server hosting the drive, not KiX. You need to address it at the server.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#162997 - 2006-06-07 06:23 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
I finally go the error report to work on a client workstation. The Error code was 0 and The Operation Completed Successfully, but the drive didn't map.
Top
#162998 - 2006-06-07 06:25 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
In order to bypass the Writeline he mentioned, I went back to the Gosub. I get error files, but even though the drive doesn't map, the error code is 0 and it says the operation completed successfully. What would I look at on the server to diagnose this?
Top
#162999 - 2006-06-07 06:27 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
Disregard my last. I see what you are talking about.
Top
#163000 - 2006-06-07 06:53 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
Would this work to capture @ERROR ?:

Code:

IF @ERROR NOT = 0
$err = @ERROR
$serr = @SERROR
If Open (1, $ErrorFile, 5) = 0
WriteLine(1, $Drive + ": " + $Path + " not mapped" + $err + "| " + $serr + "| @DATE | @TIME | @USERID | @WKSTA | @FULLNAME" + Chr(13) + Chr(10))
Close (1)
EndIf
EndIF




Edited by svivian (2006-06-07 07:32 PM)

Top
#163001 - 2006-06-07 07:04 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
I've been looking at the server trying to determine what would cause it to "pull" someone's mapped drive. Online sources suggest that it might be a licensing issue, but the "server" in question is a NAS, and shows a per-server concurrent connection limit of 9999, which I am quite sure we are nowhere near hitting. Two other factors are that the disappearing drives seem to affect only a small percentage of my user base, and prior to switching to KiX, I never heard any reports of this issue. Since the only thing that has changed in my environment is the method of mapping drives, I have to assume that the two are connected somehow, whether XP or 2003 has some issue with how KiX passes the Use command through the network, or something in how my script is written, or some other more obscure issue. Since KiX has been around so long, the fundamental principle is no doubt sound. I just need to narrow down the possibilities.
Top
#163002 - 2006-06-07 07:48 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... the server side setting I was talking about is http://support.microsoft.com/default.aspx?scid=kb;EN-US;297684
If you were mapping drives with the DOS USE command, the persistent setting may have been on by default. KiX USE does not follow the current persistent setting.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#163003 - 2006-06-07 07:53 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
svivian Offline
Fresh Scripter

Registered: 2006-06-07
Posts: 26
The problem I am having is not the "red X" issue. In my case, I have users reporting that the mapped drive literally disappears from their "My Computer" windows.
Top
#163004 - 2006-06-07 08:28 PM Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Then my guess is that you were making them persistent before and that there is some sort of network or NAS reliability issue at play here.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 3 123>


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

Who's Online
1 registered (Arend_) and 175 anonymous users online.
Newest Members
gkustra, emnipetro, Hirze, thequeen, ameliaryan
17642 Registered Users

Generated in 0.047 seconds in which 0.015 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