• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

In a login script how can I map to the users name

In a login script how can I map to the users name
Something like net use h:  \servername \ users\%username%

I am trying to remember ,is there something special to do this
0
NAMEWITHELD12
Asked:
NAMEWITHELD12
4 Solutions
 
nordtorpCommented:
Please see code below. This is a vbscript.

Set objNetwork = CreateObject("WScript.Network") 
strDriveLetter = "H:" 
strHomeServer = "\\server\users\" 
strUserName =objNetwork.UserName 
objNetwork.MapNetworkDrive strDriveLetter, strHomeServer & strUserName

Open in new window

0
 
willettmeisterCommented:
no you can do it exactly like you are saying except you need to to use proper unc convention

\\server\users\%username%

or in vb
\\\\server\\users\\%username%
0
 
oldriggerrsCommented:
It's easiest to do this in active directory. Locate the user, right click and go to properties. Click the Profile tab and fill in the local path in the home folder section. Now just have the user login and that drive is mapped.

If it has to be a login script the line should look like this:
net use u: \\servername\users\%username%

Please note the space between the u: and the \\.
0
 
Renato Montenegro RusticiIT SpecialistCommented:
Why dont you use Drive Maps?

GP Preferences Will Reduce Logon Scripts : Mapping Drives
http://blogs.technet.com/b/grouppolicy/archive/2009/02/11/gp-preferences-will-reduce-logon-scripts-mapping-drives.aspx

Note that you can use the %logonuser% variable to do what you want.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now