#162985 - 2006-06-07 12:56 AM
KiXtart logon script doesn't map all drives/sometimes drives disappear
|
svivian
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
KiX Supporter
Registered: 2002-03-27
Posts: 4672
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
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
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
|
|
|
|
#162991 - 2006-06-07 03:48 PM
Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
|
svivian
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
|
|
|
|
#162993 - 2006-06-07 05:27 PM
Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
|
svivian
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
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
|
|
|
|
#162997 - 2006-06-07 06:23 PM
Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
|
svivian
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
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
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
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
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
|
|
|
|
#163003 - 2006-06-07 07:53 PM
Re: KiXtart logon script doesn't map all drives/sometimes drives disappear
|
svivian
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 557 anonymous users online.
|
|
|