?
Solved

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

Posted on 2009-03-29
5
Medium Priority
?
384 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

800 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