Solved

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

Posted on 2009-03-29
5
381 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
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 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

821 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