Page 1 of 1 1
Topic Options
#131361 - 2004-12-15 07:45 PM Script logic help -- Roaming Profiles
misty Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 31
For everyone who is not on a laptop, I have their "My Documents" and some other folders redirected to a network share, to save overhead on copying files back and forth on login and logout. To facilitate this, I set up a domain group called "Laptop" and put all of my laptop users in it. I then added the following to my login script:

Code:
 
$RETURNCODE = EXISTKEY("HKEY_CURRENT_USER\Borkholder")
IF NOT $RETURNCODE = 0
; Add key for Borkholder-specific things on the first login
ADDKEY("HKEY_CURRENT_USER\Borkholder")
; The following key gets deleted at the end of the first login
ADDKEY("HKEY_CURRENT_USER\Borkholder\FIRST_LOGIN")
ENDIF
...
; Check to see if this is the first login -- doesn't make sense to do this
; at the very first login

$RETURNCODE = EXISTKEY("HKEY_CURRENT_USER\Borkholder\FIRST_LOGIN")
IF NOT $RETURNCODE = 0

IF NOT INGROUP("CORPSRV\Laptop")
$RETURNCODE=EXISTKEY("HKEY_CURRENT_USER\Borkholder\profile_copied")
IF NOT $RETURNCODE = 0
IF EXIST("\\corpsrv\profiles\@userID\WinXP")
copy "\\corpsrv\profiles\@userID\WinXP\My Documents\*" "\\corpsrv\@userID\"
ENDIF
IF EXIST("\\corpsrv\profiles\@userID\Win2K")
copy "\\corpsrv\profiles\@userID\Win2K\My Documents\*" "\\corpsrv\@userID\"
ENDIF
IF EXIST("\\corpsrv\profiles\@userID\WinNT")
copy "\\corpsrv\profiles\@userID\WinNT\My Documents\*" "\\corpsrv\@userID\"
ENDIF

ADDKEY("HKEY_CURRENT_USER\Borkholder\profile_copied")
WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\
User Shell Folders", "Personal","\\corpsrv\@userID","REG_SZ")
WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\
User Shell Folders", "My Pictures", "\\corpsrv\@userID\My Pictures", "REG_SZ")
IF @PRODUCTTYPE="Windows 2000 Professional" or @PRODUCTTYPE="Windows XP Professio
nal"
WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Videos", "\\corpsrv\@userID\My Videos", "REG_SZ")
WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Music", "\\corpsrv\@userID\My Music", "REG_SZ")
WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My eBooks", "\\corpsrv\@userID\My eBooks", "REG_SZ")
ENDIF $SELECTION =MESSAGEBOX("Changes were made to your registry. You must now log out
.Please save any open files and click OK", "Log Out Necessary", 0) IF $SELECTION = 1
LOGOFF(Force)
ENDIF
ENDIF
ENDIF
ENDIF



The login script is run with /f every time. This basically works. I have been noticing that sometimes after a few logins a laptop user will somehow not be shown to be in the laptop group anymore and all of a sudden they call me saying that they got a popup changing their registry. I look on the PDC and they are still in the laptop group. Then I have to go in manually and change their mappings back to the default.

Is there any way that I can tell why this doesn't always work? Both of these users are on Windows XP. One is SP1, the other is SP2.

Top
#131362 - 2004-12-15 07:57 PM Re: Script logic help -- Roaming Profiles
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Are you sure that the script runs every time and that it is just the InGroup() function that lets you down? With XP there si a possibility with Fast Logon Optimization, that the logon script not run. There is also the possibility that one of your DCs does not have a GC. You could have varying results with InGroup() depending which DC has the secure channel. You need to verify your network infrastructure. Could also be protocols and provider order.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#131363 - 2004-12-15 08:11 PM Re: Script logic help -- Roaming Profiles
misty Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 31
If the script doesn't run he would complain because he would not get any drive mappings.

Also I don't know what a GC is. I have one PDC running Samba, that serves all of my users. It is just simple Netbios over TCP/IP and it's all on the same subnet, so I don't see how this could be a protocol issue. I specifically restart the users' computer 3 or 4 times when I set him up on the domain, to be sure that he did not get the registry changes. He did not get them all yesterday, but today when he logged in, he did. When he leaves today I will run the script in debug mode as his user and see if I see anything interesting. But my feeling was more that there may be something wrong with the logic of my script. If it would be constructive, I will paste the whole thing.
Code:

break on

$RETURNCODE = EXISTKEY("HKEY_CURRENT_USER\Borkholder")
IF NOT $RETURNCODE = 0
; Add key for Borkholder-specific things on the first login
ADDKEY("HKEY_CURRENT_USER\Borkholder")
; The following key gets deleted at the end of the first login
ADDKEY("HKEY_CURRENT_USER\Borkholder\FIRST_LOGIN")
ENDIF

SETTITLE("Logging on @USERID to @LDOMAIN at @TIME")

; Set the time on the workstation
$Timeserver = "\\corpsrv"
Settime $TimeServer

; Delete all drive mappings first thing since
; Windows has a habit of hanging onto them
; We are not using "USE "*" /DELETE because there are other fileservers
; that we can't set up trusts to, that we don't want to trash their drive
; mappings.

USE "H:" /DELETE


; We need the home directory set up for the rest of the script to work
USE H: @HOMESHR
IF @ERR = 0
H:
CD @HOMEDIR
ENDIF

; People with laptops need My Documents to be in their profile. People with
; desktops can have My Documents redirected to their home directory to avoid
; long delays with logging out and out-of-sync files.

; Check to see if this is the first login -- doesn't make sense to do this
; at the very first login

$RETURNCODE = EXISTKEY("HKEY_CURRENT_USER\Borkholder\FIRST_LOGIN")
IF NOT $RETURNCODE = 0

IF NOT INGROUP("CORPSRV\Laptop")
$RETURNCODE=EXISTKEY("HKEY_CURRENT_USER\Borkholder\profile_copied")
IF NOT $RETURNCODE = 0
IF EXIST("\\corpsrv\profiles\@userID\WinXP")
copy "\\corpsrv\profiles\@userID\WinXP\My Documents\*" "\\corpsrv\@userID\"
ENDIF
IF EXIST("\\corpsrv\profiles\@userID\Win2K")
copy "\\corpsrv\profiles\@userID\Win2K\My Documents\*" "\\corpsrv\@userID\"
ENDIF
IF EXIST("\\corpsrv\profiles\@userID\WinNT")
copy "\\corpsrv\profiles\@userID\WinNT\My Documents\*" "\\corpsrv\@userID\"
ENDIF

ADDKEY("HKEY_CURRENT_USER\Borkholder\profile_copied")
WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal","\\corpsrv\@userID","REG_SZ")
WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Pictures", "\\corpsrv\@userID\My Pictures", "REG_SZ")
IF @PRODUCTTYPE="Windows 2000 Professional" or @PRODUCTTYPE="Windows XP Professional"
WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Videos", "\\corpsrv\@userID\My Videos", "REG_SZ")
WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My Music", "\\corpsrv\@userID\My Music", "REG_SZ")
WRITEVALUE("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "My eBooks", "\\corpsrv\@userID\My eBooks", "REG_SZ")
ENDIF
$SELECTION =MESSAGEBOX("Changes were made to your registry. You must now log out.Please save any open files and click OK", "Log Out Necessary", 0)
IF $SELECTION = 1
LOGOFF(Force)
ENDIF
ENDIF
ENDIF
ENDIF

IF INGROUP("CORPSRV\Domain Admins")
USE Z: \\corpsrv\everything
SETCONSOLE("show")
ELSE
; Nobody cares about seeing the login script except admins
SETCONSOLE("hide")
ENDIF


IF INGROUP("CORPSRV\Acct_Admin","CORPSRV\HR")
USE I: \\CORPSRV\HR_PR
; Eventually ABRA mapping will be here
ENDIF


IF INGROUP("CORPSRV\Acct")
; Set up printer
$RETURNVALUE = existkey("HKEY_CURRENT_USER\Printers\,,corpsrv,acct_hp8500")
IF NOT $RETURNVALUE = 0
ADDPRINTERCONNECTION("\\corpsrv\acct_hp8500")
SETDEFAULTPRINTER("\\corpsrv\acct_hp8500")
ENDIF
; Set up drive mappings
USE M: \\corpsrv\ACCT

ENDIF


IF INGROUP("CORPSRV\Engr","CORPSRV\Truss","CORPSRV\Receptionist")
$RETURNVALUE = EXISTKEY("HKEY_CURRENT_USER\Printers\,,corpsrv,engr_hp1300")
IF NOT $RETURNVALUE = 0
ADDPRINTERCONNECTION("\\corpsrv\engr_hp1300")
USE LPT3: "\\corpsrv\engr_hp1300"
ENDIF
; Make sure the user can run MATLIST -- they need a .get file and it gets
; created automatically if they don't have one (copied from one that works)
IF NOT EXIST("\\corpsrv\data\batch\paths\@USERID.get")
copy \\corpsrv\data\batch\paths\jenny.get \\corpsrv\data\batch\paths\@USERID.get
ENDIF

; The program was written to use a variable that exists in Novell but not NT, so we set it here
SETM "LINAME=@USERID"
? "LINAME set to @USERID" ; for MATLIST program -- look in %L\DATA\BATCH\PATHS\username.get

; Set up drive mappings here (X will go away eventually)
USE L: \\corpsrv\engr
USE G: \\corpsrv\apps
USE Q: \\corpsrv\data
USE U: \\corpsrv\utils
use X: \\corpsrv\X
ENDIF

IF INGROUP("CORPSRV\Truss")
; Don't set up a default printer, they choose which one they want
$RETURNVALUE = EXISTKEY("HKEY_CURRENT_USER\Printers\Connections\,,corpsrv,truss_hp4")
IF NOT $RETURNVALUE = 0
ADDPRINTERCONNECTION("\\corpsrv\truss_hp4")
ENDIF
$RETURNVALUE = EXISTKEY("HKEY_CURRENT_USER\Printers\Connections\,,corpsrv,truss_hp5n")
IF NOT $RETURNVALUE = 0
ADDPRINTERCONNECTION("\\corpsrv\truss_hp5n")
ENDIF
$RETURNVALUE = EXISTKEY("HKEY_CURRENT_USER\Printers\Connections\,,corpsrv,truss_hp4050")
IF NOT $RETURNVALUE = 0
ADDPRINTERCONNECTION("\\corpsrv\truss_hp4050")
ENDIF
ENDIF


; Everyone gets the N drive
USE N: \\corpsrv\network

$RETURNVALUE = EXISTKEY("HKEY_CURRENT_USER\Borkholder\FIRST_LOGIN")
IF $RETURNVALUE = 0
DELKEY("HKEY_CURRENT_USER\Borkholder\FIRST_LOGIN")
ENDIF




Edited by misty (2004-12-15 09:58 PM)

Top
#131364 - 2004-12-15 09:49 PM Re: Script logic help -- Roaming Profiles
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I can't seem to find the "IF" that the "ELSE" below goes with...

Code:

USE Z: \\corpsrv\everything
SETCONSOLE("show")
ELSE
; Nobody cares about seeing the login script except admins
SETCONSOLE("hide")
ENDIF

_________________________
Eric

Top
#131365 - 2004-12-15 09:59 PM Re: Script logic help -- Roaming Profiles
misty Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 31
Sadly that was a pasting error. It's corrected in my post.
Top
#131366 - 2004-12-16 02:43 PM Re: Script logic help -- Roaming Profiles
misty Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 31
I found the problem. When I was checking for the groups I was using SERVERNAME\GROUP rather than DOMAIN\GROUP. This confusion came up from an earlier problem. Changing it to the correct syntax for group checking seems to have fixed the problem.
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 515 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.147 seconds in which 0.116 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