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.
- Log on to the domain controller with administrator account.
- 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.
- Save this file with any name but .BAT extension. In this example it can be MapDrive.BAT.
- Close the file and copy it.
- While logging on to the domain controller with administrator account click on Start button and from the start menu go to Administrative Tools.
- From the submenu click on Active Directory Users and Computers.
- 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.
- In Properties box go to Group Policy tab and click on New button.
- Name the newly created group policy object as MapNetworkDrive.
- Click on Edit button to open the snap-in for the newly created group policy object.
- In the opened snap in under User Configuration expand Windows Settings and select Scripts (Logon/Logoff).
- From the right pane double click on Logon script.
- On Log on Properties box click on Add button.
- On Add a Script box click on Browse button.
- In the opened box paste the copied batch file that you have created in the previous section and click on Open button.
- Back on Add a Script box click on Ok button and again click on Ok button on Logon Properties box.
- Close the opened snap-in and open Command Prompt.
- On the opened command prompt window type gpupdate /force command to update the group policy settings.