Skip to content

How to Create and Use Logon Script to Map a Shared Folder as Network Drive for All Domain Users in Windows Server 2003?

By Codrut Nistor

Posted in How-to, Windows-server-2003

Logon scripts are the batch files that contain some instructions and/or commands that are to be executed whenever a user logs on to the system. Logon scripts are configured using group policy objects which can then be linked to either an organizational unit or to the entire domain. This tutorial will tell you how to configure the group policy object so that it can automatically map the shared folder (or the DFS root folder) whenever any domain user logs on to the domain. You can configure group policy object for Logon Scripts by following the steps given below:

The complete process has two sections.

Section 1

  1. Log on to the domain controller with administrator account.
  2. Open Notepad and type the share path of the folder that you want to map as a network drive. In this example it can be net use z: \testdomain.com\MyRoot which is the path of DFS root folder.
  3. Save this file with any name but .BAT extension. In this example it can be MapDrive.BAT.
  4. Close the file and copy it.

Section 2

  1. While logging on to the domain controller with administrator account click on Start button and from the start menu go to Administrative Tools.
  2. From the submenu click on Active Directory Users and Computers.
  3. On Active Directory Users and Computers snap-in right-click on the domain name (which is TESTDOMAIN.COM in this example) and click on Properties.
  4. In Properties box go to Group Policy tab and click on New button.
  5. Name the newly created group policy object as MapNetworkDrive.
  6. Click on Edit button to open the snap-in for the newly created group policy object.
  7. In the opened snap in under User Configuration expand Windows Settings and select Scripts (Logon/Logoff).
  8. From the right pane double click on Logon script.
  9. On Log on Properties box click on Add button.
  10. On Add a Script box click on Browse button.
  11. In the opened box paste the copied batch file that you have created in the previous section and click on Open button.
  12. Back on Add a Script box click on Ok button and again click on Ok button on Logon Properties box.
  13. Close the opened snap-in and open Command Prompt.
  14. On the opened command prompt window type gpupdate /force command to update the group policy settings.