//flex table opened by JP

Click to See Complete Forum and Search --> : Win2000 DC Login script


burgerp
11-18-2003, 05:39 AM
I need a login script that handle all operating systems logging into a Win2000 domain controller. All I want is for the script to map the user home folders amd then another drive or two. I do not want to append all users in the AD with all the info. I can get the script to map additional drives but not the home folders. If I specify each of the user's home folder drive and location in the AD the home folders also map but it will take me a year.

My login script in winnt\sysvol\sysvol\domainname\scripts looks like this :

net use h: /home /y
net use k: \\servername\finance /y %switch%
net use s: \\servername\apps /y %switch%

Thanks.

burgerp
11-19-2003, 08:40 AM
Use the following script and save it as a .vbs file. Run the file on the DC with cscript filename.vbs. It will change all the Home folder paths according to the data you put in. It will also create your home folders. You can use it on a existing domain as it will not override the data and folders that already exist.

All you have to do then is to share the new folders and input your login script's location for each user in the AD. It saved me at least 2 days time.


Sub GetParentDir
ParentDir = InputBox("Type the path of the parent folder for the user folders:", "Parent Directory Input Prompt", ParentDir)
If Not FS.FolderExists(ParentDir) Then
GetParentDir
End If
End Sub

Dim WSHNetwork, WSHShell, FS, Domain, DomainObj, Computer, ShareServiceObj, ParentDir, Hidden, Drive
Set FS = CreateObject("Scripting.FileSystemObject")
Set WSHNetwork = CreateObject("WScript.Network")
Set ShareServiceObj = GetObject("WinNT://" & WSHNetwork.ComputerName & "/LanManServer")

Domain = InputBox("Type the name of your domain:","Enumeration and Creation of User Shares","DomainName")
ParentDir = "C:\Users"
GetParentDir
Hidden = MsgBox("Do you want the user shares to be hidden? If yes, the share will be username$; If no, the share will be username", 4, "Hidden Shares?")
Hidden = Hidden - 7
Drive = InputBox("What drive letter do you want to map the home folder to?", "Drive Letter?", "X:")
Set DomainObj = GetObject("WinNT://" & Domain)
DomainObj.Filter = Array("User")

For Each UserObj in DomainObj
Dim ShareName
If Not FS.FolderExists(ParentDir & "\" & UserObj.Name) Then
FS.CreateFolder(ParentDir & "\" & UserObj.Name)
End If
ShareName = UserObj.Name
If Hidden Then
ShareName = ShareName & "$"
End If
On Error Resume Next
Set NewShare = ShareServiceObj.Create("fileshare", ShareName)
If Not Err Then
NewShare.Path = ParentDir & "\" & UserObj.Name
NewShare.MaxUserCount = 1 'Sets the limit for the number of user connections
NewShare.SetInfo
UserObj.HomeDirectory = "\\" & WSHNetwork.ComputerName & "\" & ShareName
UserObj.HomeDirDrive = Drive 'Requires ADSI 2.5
UserObj.SetInfo
End If
Next

MsgBox "Script Complete",, "Finished"