Link to home
Start Free TrialLog in
Avatar of jameso99
jameso99Flag for United States of America

asked on

Windows Login Script mapping User Home Folders

I would like to map my users' home data folder (i.e. \\server\d\data\James_Files) to the Z drive in my login script.  Right now I just map the drives in this fasion:

' Login Script v 0.3
' Modified 9/29/2006

'-------------------------------------------------------------------
' Set up
Dim WshShell
Dim WshNetwork
Dim UserIn

Set WshShell = CreateObject("WScript.Shell")
Set WshNetwork = CreateObject("WScript.Network")

'-------------------------------------------------------------------
' Map network drives

' Disconnect all network drives first
On Error Resume Next
Set colDrives = WshNetwork.EnumNetworkDrives()

For i = 0 to colDrives.Count-1 Step 2
    WshNetwork.RemoveNetworkDrive colDrives.Item(i), True
Next

' Now Map the New ones
WshNetwork.MapNetworkDrive "M:", "\\server\D"
WshNetwork.MapNetworkDrive "N:", "\\server\Archive"

' Map user's home directory
'UserIn = WshNetwork.UserName
'WshNetwork.MapNetworkDrive "Z:","\\server\D\Data\" & UserIn & "$"
'WScript.Echo "Welcome " & UserIn

'-------------------------------------------------------------------
' Add Networked printers from the server
'-------------------------------------------------------------------
WScript.Quit


My problem is that the user name (i.e. "james") is not the same as the folder in the DATA folder I have set up ("James_Files" or whatever).  I did not originally set this up, otherwise I would have made it a lot easier on myself!

Is there a way I can map the user's home folder, using AD or something, to this drive letter?

Thanks SO much people!
Avatar of 2hype
2hype
Flag of Canada image

How many users do you have?  Are the Data files standard?  can you not map a drive to "\\Servername\D\Data\" & UserIn & "_Files$"

If james logs in will his home directory be james_files
   Sue logs in sue_files
   ect...

You could go into each user in Active Directory, Go to Profiles - Go to Home folder and connect Z:  to there home drive for each user.


 
SOLUTION
Avatar of usacadena
usacadena

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Kevin Hays
Kevin Hays
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Really, you probably need a way to modify large groups of user objects with a script that will modify the "home" directory to "\\servername\home\%username%" instead of having to go through each one manually though.

Kevin
I see what's going on here.  This should be pretty easy to fix but you will have to add a comment for each user in ADUC.

Add the folder path to the description field of the user object then use the following lines to query this value.  The variable desc will hold whatever string is typed into the description field in the AD user Object.

You will have to incorporate this into your logon script and will use a line like"
WshNetwork.MapNetworkDrive "Z:",desc
to map the drive


'~~~~~~START~~~~~~~~
Option Explicit
Dim ADInfo, ADUser, desc

Set ADInfo = CreateObject("ADSystemInfo")
Set ADUser = GetObject("LDAP://" & ADInfo.UserName)

desc = ADUser.description
'~~~~~~~~~END~~~~~~~~~~

If this is not what you want then please let me know.  I'm assuming the user's data folders are all over the place or do not follow any standard naming.  If they follow some kind of standard naming and are all in the same share let me know and I can do something much easier for you.

Assumed:
Users data folders are setup something like this

Username: James
data folder: \\server1\data\james_files

Username: Sue
data folder: \\server1\data\sue_data

Username: Fred
Data Folder: \\server2\someshare\Fred_files
Avatar of jameso99

ASKER

Thanks guys.  I liked kshay's implementation with using the AD groups from LDAP AD.  Sounds like I may just rename some folders and totally redo this whole thing.

Thanks,

James.
Anytime, Good luck jameso99.

Kevin