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

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

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
mystikal1000
Asked:
mystikal1000
1 Solution
 
ITHelper80Commented:
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
 
ITHelper80Commented:
0
 
RobSampsonCommented:
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
 
supportemeaCommented:
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
 
unassassinableCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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