View Full Version : Speeding up login scripts
cbraun
01-15-2002, 11:38 PM
Does anyone have or know where I can find (If such a thing exists) a sample of a windows login script (in vbs) that when a user logs in to the domain will perform the following tasks:
Determine what global groups the user is in.
Map appropriate drives based on the groups.
Currently our script contains a list of groups and says if the user is a member of this group, map this drive then if the user is a member of that group, map that drive etc. This works, but is slow and I am wondering if the process could be speeded up by first determining all the groups the person is a member of and then mapping the drives accordingly.
We hope for something that will work across all windows platforms.
Thanks for your replies.
freemancc
01-31-2002, 07:58 AM
before run the script, you must define the default group for every user, the scipt is worked by using the default group which define in NT Server
'************************************************* *****************************************
' Author : Freeman Wong
' Created : 9 May 2001
' Last Modified : 23 May 2001
' Version : 1.5
' Description : This script will map Department Drive for the users
'************************************************* *****************************************
'************************************************* *****************************************
' Define all department groups
'************************************************* *****************************************
PriGroup1 = "MIS"
PriGroup2 = "HR"
PriGroup3 = "Sales"
PriGroup4 = "Finance"
PriGroup5 = "Test1Group5"
PriGroup6 = "Test1Group6"
PriGroup7 = "Test1Group7"
PriGroup8 = "Test1Group8"
PriGroup9 = "Test1Group9"
PriGroup10 = "Test1Group10"
PriGroup11 = "Test1Group11"
PriGroup12 = "Test1Group12"
PriGroup13 = "Test1Group13"
PriGroup14 = "Test1Group14"
PriGroup15 = "Test1Group15"
'************************************************* *****************************************
' Initial Setup
'************************************************* *****************************************
Dim Username, CheckGroup, DomainName, UserRegPath, NetPath, OSType
Username = ""
CheckGroup = ""
DomainName = "leogroup"
DeptServer = "HKDATA01"
DeptDrive = "O:"
UserRegPath = "HKLM\Software\LEO PAPER GROUP\User Info\"
OSRegPath = "HKLM\Software\LEO PAPER GROUP\System Info\"
set WshShell = Wscript.CreateObject("Wscript.Shell")
SystemRoot = WshShell.ExpandEnvironmentStrings("%Windir%") & "\"
OSType = WshShell.RegRead(OSRegPath & "OS Type")
'************************************************* *****************************************
On Error Resume Next
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
While Username = ""
' Get Current Logon Name
UserName = WshNetwork.UserName
dsRoot = "WinNT://" & DomainName & "/" & Username
set Usr = GetObject(dsRoot)
For Each Prop In Usr.groups
' Wshshell.popup Prop.Name
Select Case Prop.Name
Case PriGroup1
CheckGroup = PriGroup1
Exit For
Case PriGroup2
CheckGroup = PriGroup2
Exit For
Case PriGroup3
CheckGroup = PriGroup3
Exit For
Case PriGroup4
CheckGroup = PriGroup4
Exit For
Case PriGroup5
CheckGroup = PriGroup5
Exit For
Case PriGroup6
CheckGroup = PriGroup6
Exit For
Case PriGroup7
CheckGroup = PriGroup7
Exit For
Case PriGroup8
CheckGroup = PriGroup8
Exit For
Case PriGroup9
CheckGroup = PriGroup9
Exit For
Case PriGroup10
CheckGroup = PriGroup10
Exit For
Case PriGroup11
CheckGroup = PriGroup11
Exit For
Case PriGroup12
CheckGroup = PriGroup12
Exit For
Case PriGroup12
CheckGroup = PriGroup12
Exit For
Case PriGroup13
CheckGroup = PriGroup13
Exit For
Case PriGroup14
CheckGroup = PriGroup14
Exit For
Case PriGroup15
CheckGroup = PriGroup15
Exit For
End Select
Next 'Prop
WEnd
NetPath = "\\" + DeptServer + "\" + CheckGroup + "$"
If CheckGroup <> "" Then
'Map Department Drive
WshNetwork.MapNetworkDrive DeptDrive, NetPath
WshShell.RegWrite UserRegPath & "DepartmentDrivePath", NetPath
WshShell.RegWrite UserRegPath & "Department", CheckGroup
If OSType <> "" or OSType <> "Windows_NT" Then
WshShell.Run("wscript \\HKBDC01\NETLOGON\" + CheckGroup + "\MapRestrictedDrv.vbs")
Else
WshShell.Run("SET DEPARTMENT " + Checkgroup)
End If
Else
WshShell.RegWrite UserRegPath & "Department", "None"
End If
Powered by vBulletin™ Version 4.1.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.