Solved

Script to map home drive for users

Posted on 2007-11-19
9
3,667 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:vmamedov
9 Comments
 

Author Comment

by:vmamedov
ID: 20314370
I would also like to use DFS, so the location of the home drive would be \\domain\share\share\username$
0
 
LVL 6

Expert Comment

by:MorDrakka
ID: 20314419
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
 

Author Comment

by:vmamedov
ID: 20314444
I have tried that and it doesnt work, it doesnt map the drive,
also i am looking for a vb script not batch
0
 
LVL 12

Accepted Solution

by:
chandru_sol earned 500 total points
ID: 20314470
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:MorDrakka
ID: 20314478
arg C beat me again. /sigh
0
 

Author Comment

by:vmamedov
ID: 20314805
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
 

Author Comment

by:vmamedov
ID: 20314942
i figured out what i was doing, there was a problem with DFS

thanks both
0
 

Expert Comment

by:AdrianWhitehurst
ID: 20375105
How did you fix the issue? I am getting same error when I run the script.
0
 

Author Comment

by:vmamedov
ID: 20382253
adrian whats is the problem that you are having?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now