[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

I need a script that will automatically map drives at login.

Posted on 2009-03-29
5
Medium Priority
?
388 Views
Last Modified: 2012-05-06
I need a script that will automatically map drives at login.  The script will be used only on a specific terminal server and users, I don't want to setup a gpo.  I want the script to be seamless to the user and non-persistent, I don't want the mapped drives to be saved to their profile.  The script should resume on error for any customer that is having any permission problems.  Can I use the usrlogin.cmd script, would that work or would I need a vbs script?
I would like the following mapped drives for all users accessing this particular server.
k:=\\server1\test
m:=\\server2\test2
o:=\\server3\test3

Can anyone help me with this problem.

Thanks!
0
Comment
Question by:mystikal1000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Expert Comment

by:ITHelper80
ID: 24013903
You can use a .batch  file and put it in the startup folder.
Use the syntax below in a text file and save it as "filename".bat

Syntax for mapping a network drive:
NET USE devicename \\computername\sharename /PERSISTENT:{YES|NO}
devicename  - are any unused drive from D: through Z:
persistent - yes means "reconnect at logon" and no means don't "reconnect at logon"
Examples:
NET USE U: \\lf111-server\data\users /PERSISTENT:NO
maps the U: drive to the users share and without reconnecting at next logon
NET USE F: \\lf111-server\data /PERSISTENT:YES
maps the F: drive to the data share and reconnects F: to it at subsequent logons
0
 
LVL 6

Expert Comment

by:ITHelper80
ID: 24013908
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 24014385
If you want the drives mapped for all users, and it's just one server, then modifying usrlogon.cmd will be fine.  Or even, leave your code in \\MYDC\NetLogon\TSLogon.cmd, and just add
Call \\MYDC\NetLogon\TSLogon.cmd

to usrlogon.cmd on that server.  Then, the below would be the contents of TS_Logon.cmd

@echo off
NET USE K: \\server1\test /PERSISTENT:NO
NET USE M: \\server2\test2 /PERSISTENT:NO
NET USE O: \\server3\test3 /PERSISTENT:NO

Regards,

Rob.
0
 
LVL 2

Accepted Solution

by:
supportemea earned 2000 total points
ID: 24017821
Here ya go
Option Explicit
Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3, strRemotePath4
Dim strDriveLetter1, strDriveLetter2, strDriveLetter3, strDriveLetter4
 
 
strDriveLetter1 = "z:" 
strDriveLetter2 = "x:" 
strDriveLetter3 = "y:"
strDriveLetter4 = "w:"
 
strRemotePath1 = "\\fileserver\share1" 
strRemotePath2 = "\\fileserver\share2"
strRemotePath3 = "\\fileserver\share3"
strRemotePath4 = "\\fileserver\share4"
on error resume next
 
 
Set objNetwork = CreateObject("WScript.Network") 
 
 
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3
objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4
 
WScript.Quit 

Open in new window

0
 
LVL 9

Expert Comment

by:unassassinable
ID: 24057286
Here is the how to so you can learn for yourself directly form Microsoft Technet:

http://technet.microsoft.com/en-us/library/cc758918.aspx
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

650 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