Script to map home drive for users

Currenly I mapping a users "h" home drive with an entry in the users properties under the home folder path. I would like to script so that when users log in they are mapped to their h drive on a server.

Each user has a shared with with the correct permissions on the server. The share is username$
So in the home folder properties its \\server\username$

Thanks in advance
vmamedovAsked:
Who is Participating?
 
chandru_solConnect With a Mentor Commented:
Try this..........


regards
Chandru
Set objSysInfo = CreateObject("ADSystemInfo")
 
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
 
strUserName = objUser.samAccountName
 
strDrive = "\\domain\share\share\" & strUserName & "$"
 
Set objNetwork = CreateObject("Wscript.Network")
objNetwork.MapNetworkDrive "H:", strDrive

Open in new window

0
 
vmamedovAuthor Commented:
I would also like to use DFS, so the location of the home drive would be \\domain\share\share\username$
0
 
MorDrakkaCommented:
Hi,

As i understand correctly, you do NOT wish to use the AD integrated homefolder option en want to script it ?

How about this in the loginscript:

Net use H: \\domain\share\share\%username%$

Where you use the environment variable %username%

If I do not understand correctly please say so :p

M
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
vmamedovAuthor Commented:
I have tried that and it doesnt work, it doesnt map the drive,
also i am looking for a vb script not batch
0
 
MorDrakkaCommented:
arg C beat me again. /sigh
0
 
vmamedovAuthor Commented:
chandru, thanks for your help
after running the script i am getting the following error

---------------------------
Windows Script Host
---------------------------
Script:      C:\Documents and Settings\user\Desktop\hdrives.vbs
Line:      11
Char:      1
Error:      The system cannot find the file specified.

Code:      80070002
Source:       WSHNetwork.MapNetworkDrive

---------------------------
OK  
---------------------------
0
 
vmamedovAuthor Commented:
i figured out what i was doing, there was a problem with DFS

thanks both
0
 
AdrianWhitehurstCommented:
How did you fix the issue? I am getting same error when I run the script.
0
 
vmamedovAuthor Commented:
adrian whats is the problem that you are having?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.