|
General -
General
|
|
Written by Sandeep Narkhede
|
|
Monday, 01 February 2010 12:30 |
Automatic Drive Mapping using Logon Script
Drive Mapping,Logon Script | Problem and Solution
This one comes after a real long time, I was busy shifting my residence & getting familiar with the new place where I stay. things have settled down now & time to be back with thing that I enjoy, writing about my latest experience dealing with issues related to Exchange & Active Directory.
I was asked to work on a logon script that enables the user to automatically map some network drives when they login to the domain. Being a core Messaging person I wasn't too familiar with the requirement, but like all other days I figured it out quickly.
First of all I need to know which drives needs to be mapped & to which drive letters, so for example say that i have two drives that i need to map to Drive Letters V & W

1. So i need to ensure there are no drive mappings with these dive letters that user has done manually, for this I use following command which remove any drive mappings with the letters V & W
NET USE V :/Delete NET USE W:/Delete
2. Then I need to add my Drive Mapping to these drive letters, say that the drives that i need to map are
\\192.168.1.1\Share1 & 192.168.1.1\Share2
NET USE V:\\192.168.1.1\share1 NET USE W:\\192.168.1.1\Share2
3. I also was told that I have two set of groups that would need two different Drive Mappings, Like sales people will need different Mapping with Drive J & K that corresponds to a different Network Drives which are \\192.168.1.1\Sales1
& \\192.168.1.1\Sales2
I added the sales users to a group called SALES_GROUP & finally made a complete script which looked like following.
ECHO OFF
IF NOT %errorlevel% EQU 1 GOTO NORMAL_USERS
NET USE J :/Delete NET USE K:/Delete NET USE J:\\192.168.1.1\Sales1 NET USE K:\\192.168.1.1\Sales2
:NORMAL USERS
IFMEMBER NORMAL_USERS
IF NOT %errorlevel% EQU 1 GOTO QUIT NET USE V :/Delete NET USE W:/Delete NET USE V:\\192.168.1.1\Share1 NET USE W:\\192.168.1.1\Share2
:QUIT
exit
This worked like a charm, only problem was when the users login to their laptops with the cached credentials, ( outside the corporate network) these drive mappings caused timeouts to these drives causing extreme slow performance logging in ...causing lot of frustration.....

.......So we modified the script to use non persistent mapping ( equivalent to uncheck the box "Automatically connect at the next logon)
For this we need to post fix every Net Use command that maps a drive with /Persistent:No , this resolved my final issue with this small but interesting task....

IFMEMBER SALES_GROUP
|