Saturday, November 15, 2008

Mapping network drives with login scripts

Mapping network drives with login scripts
To access resources on the network, users can either use My Network Places or the
Universal Naming Convention (UNC) of the share. If there are shares that users need to
access on a regular basis, it is best to map a drive to that share. This makes it very easy for
users to access the resource by using My Computer and double-clicking on the drive letter of
the share, just as they would access the hard drive or the CD-ROM on their computer. Login
scripts enable the administrator to map drives to network shares automatically every time the
user logs in.
1. Log in to DC1 as the Administrator. On the desktop, double click My Computer then
double click the C: drive and select File 􀃆 New 􀃆 Folder. Name the folder HR when
prompted. Then, right click HR, select Sharing and Security and select Share this
folder. Click OK.







You have now created a folder named HR and shared it. Using the same steps, create
two other shares, Production and Sales. At the end of this step, you should have three
shares - HR, Production and Sales. You will map the X: Y: and Z: drives to these shares
respectively.

2. Next, you will create a login script using a batch file. To do this, open notepad and click
Start 􀃆 Run and type in notepad. Click OK. Now click Start 􀃆 Administrative
Tools 􀃆 Group Policy Management. Right click CA and select Create and Link a
GPO here. Type DriveMapping in the name box and click OK.




3. In the notepad window, type the following lines of code:
net use x: \\dc1\hr
net use y: \\dc1\production
net use z: \\dc1\sales




4. Click File 􀃆 Save As then select C: in the Save in box and type login.bat for the File
name. Click Save.



You have just created a login script called login.bat and saved it to the C: drive. The
syntax to map a drive using commands is:
net use : \\servername\sharename

5. In the Group Policy objects container, right click DriveMapping 􀃆 Edit 􀃆 User
Configuration 􀃆 Windows Settings and select Scripts (Logon/Logoff).




6. In the right hand pane, double click Logon to open the Logon Properties box. Click the
Show Files button. This opens up a policies window. Keep this window open and
copy the file login.bat from C: to this window.



7. Copy the file by going to the C: drive in My Computer and locating the login.bat file that
you created in an earlier step. Right click login.bat and select Copy.



8. Switch to the policies window you opened previously and paste login.bat into this
window by selecting Edit 􀃆 Paste. This will copy the login.bat file to this window.
Close the window. Then, in the Logon Properties screen, click Add.



9. Click Browse in the Add a Script window, select login.bat and click Open. Click OK
to close the dialog box.



10. Click OK to finish adding the login script. Close the Group Policy Object Editor
window and the Group Policy Management window.



To summarize, you have done the following:
􀀹 Created a login script using Notepad.
􀀹 Created a GPO.
􀀹 Edited the GPO by copying the login.bat file at the appropriate location.

No comments:

Post a Comment