There are two ways to assign Logon scripts. First, you can specify the Logon script on the "Profile" tab of the user properties dialog in the Active Directory Users and Computers MMC. Second, you can specify a Logon script in Group Policy.
You would assign a Logon script on the "Profile" tab of the user properties if you have client computers with Windows 95, Windows 98, Windows ME, or Windows NT. Group Policy is not applied on computers with these operating systems. If all of your clients have at least Windows 2000, you could use Group Policy to assign Logon scripts.
You can, but if a user logs on to a computer with Windows 2000 or above, both Logon scripts will run.
If your users can Logon to both older clients (like Windows 95, Windows 98, Windows ME, or Windows NT) and the newer clients (like Windows 2000 and Windows XP), you should assign a batch file as the Logon script on the "Profile" tab for each user in the Active Directory Users and Computers MMC. The batch file can launch a VBScript program, as explained below. Once all of your clients are at least Windows 2000, you can use a VBScript program as the Logon script, and use Group Policy to assign Logon scripts to all users in a domain, site, or organizational unit.
The field labeled "Logon script" on the "Profile" tab of the user properties dialog in the Active Directory Users and Computers MMC corresponds to the "scriptPath" attribute of the user object. The default location for Logon scripts specified by this attribute is the NetLogon share. By default, all users have read access to this share. The NetLogon share on the Domain Controller is located in the following folder:
%SystemRoot%\sysvol\sysvol\<domain DNS name>\scripts
where %SystemRoot% is usually "c:\winnt" and <domain DNS name> is the DNS name of the domain, similar to "MyDomain.com". This folder is replicated to all Domain Controllers in the domain. The usual practice is to enter the name of the Logon script, for example "NetLogon.bat", in the field labeled "Logon script" on the "Profile" tab for the user and place this file in the NetLogon share. The Logon script will run for the user when they Logon to any computer that is joined to the domain. You can also enter a UNC path in the "Logon script" field and place the file in another location. However, this location should be one that is replicated to all Domain Controllers. Alternatively, you can use a script or utility to assign the Logon script to the "scriptPath" attribute of the user object in Active Directory. A VBScript program to assign a value to this attribute for many users in bulk would be much faster than manually entering values for users one at a time in the MMC.
If the client operating system (OS) is Windows 95, Windows 98, or Windows ME, the Logon script must be a batch file (with extension .bat) or executable program (with extension .exe). If the client operating system is Windows NT, the Logon script can be a batch, command, or executable file (with extension .bat, .cmd, or *.exe). If the client is Windows 2000 or above, the Logon script can be a batch file, a command file, executable program (with extension *.bat, *.cmd, *.exe), or a program written in a language hosted by Windows Script Host (WSH). Examples of WSH supported languages are VBScript (with extension *.vbs) and JScript (with extension *.js). The type of Logon script you use should support all clients you expect the user to Logon to. However, a VBScript, JScript, or other WSH hosted program would be the most powerful. Other languages supported by WSH are Perl, REXX, and Python. However, the script engines for these languages must be registered with Windows. VBScript and JScript are installed on all clients with Windows 2000 or above, and is installed with DSClient on all other clients.
Another option that should be mentioned is KiXtart. This tool was available in the NT Server resource kit and provides logon script functionality for all clients.
Yes. The client operating system must be at least Windows 2000 in order for the actual specified logon script to be a VBScript program. All older clients should have a batch file defined as the Logon script. If any of your clients have Windows 95, Window 98, Windows ME, or Windows NT, it is recommended that you designate a batch file as the logon script for all users. Fortunately, the batch file can simply launch a VBScript program. The only requirement is that Windows Script Host (WSH) and VBScript be installed on the client. Clients with Windows 2000 or above come with WSH and VBScript. WSH and VBScript are installed with DSClient on Windows 95, Windows 98, and Windows ME. The DSClient for Windows NT also includes WSH and VBScript. There is also a separate installation of WSH and VBScript available if you don't want to install DSClient on your Win9x or NT machines. However, if you install WSH and VBScript instead of DSClient on machines with Win9x or NT, you cannot use ADSI to retrieve information from Active Directory, such as group membership information. ADSI is built into clients with Windows 2000 or above.
An example of a batch file Logon script that launches a VBScript program is as follows:
The "%0" in the batch file is interpreted by the command processor to be the name and path of the current file, which is the batch file itself. The string "%0\..\" then becomes the folder where the batch file is stored. The batch file above will launch the VBScript program NetLogon.vbs as long as it is saved in the NetLogon share with the batch file. This syntax is preferable to a UNC path, because it does not hard code the name of a Domain Controller. The syntax will work no matter which Domain Controller authenticates the user. The logon script will work no matter which Domain Controllers are available or where in the network the user logs on.
Logon scripts can also be configured in Group Policy. However, Group Policy only applies to clients with Windows 2000 or above. The setting in Group Policy is "User Configuration", "Windows Settings", "Scripts (Logon/Logoff)", "Logon". Best practice is to copy the file you want for the Logon script to the Windows clipboard, open the "Logon" setting in the Group Policy editor, press the "Show Files..." button, and paste the desired file in the dialog. You can select the file and edit it in this dialog as well. This is easier than navigating in Windows Explorer to the folder where Group Policy Logon scripts are saved. However, if you do have to navigate to the folder, the path on the Domain Controller is:
%SystemRoot%\sysvol\sysvol\<domain DNS name>\Policies\<GUID>\user\scripts\logon
Again, %SystemRoot% is usually "c:\winnt" or "c:\Windows" and <domain DNS name> is the DNS name of the domain, similar to "MyDomain.com". <GUID> is a hexadecimal string representing the GUID (unique identifier) of the specific Group Policy Object (GPO).
The sysvol directory is shared so this path is also:
\\<Server>\sysvol\<domain DNS name>\Policies\<GUID>\user\scripts\logon
where <Server> is the NetBIOS name of the server. Group Policies are assigned to a domain, site, or organizational unit in Active Directory. The Logon script setting applies to all users in the domain, site, or organizational unit to which the GPO applies. You will notice that you assign a Logon script to all users in the container at once, rather than having to assign the "scriptPath" attribute for each user. This makes it much easier to assign Logon scripts to many users. However, since the same Group Policy applies to all users in the domain, site, or organizational unit, you must code the Logon script to accommodate all users.
Group Policy can also be used to assign Logoff, Startup, and Shutdown scripts. The Logoff script setting in Group Policy is "User Configuration", "Windows Settings", "Scripts (Logon/Logoff)", "Logoff". Similar to the Logon script setting, it applies to all users in the domain, site, or organizational unit that the GPO is assigned to. Startup and Shutdown scripts are in "Computer Configuration", "Windows Settings", "Scripts (Startup/Shutdown)". These scripts are applied to any computer in the domain, site, or organizational unit that the Group Policy is applied to. There is no provision for running Logoff, Startup, or Shutdown scripts on computers with Windows 95, Windows 98, Windows ME, or Windows NT.
It is much easier to create and modify these scripts in the Group Policy editor, as described in #8 above, but if you must navigate to the actual folders on the Domain Controller they are as follows:
\\<Server>\sysvol\<domain DNS name>\Policies\<GUID>\user\scripts\logoff
\\<Server>\sysvol\<domain DNS name>\Policies\<GUID>\machine\scripts\startup
\\<Server>\sysvol\<domain DNS name>\Policies\<GUID>\machine\scripts\shutdown
Logon and Logoff scripts run with the credentials of the user. It is recommended that the group "Domain Users" be given permission to any resources used by either of these scripts. For example, if the Logon or Logoff script writes to a log file, the group "Domain Users" should be given read/write access to the file or the folder where the log file is located. Most users have limited privileges on the local computer, so Logon and Logoff scripts will have the same limited privileges.
Startup and Shutdown scripts run with the credentials of the computer object. It is recommended that the group "Domain Computers" be given permission to any resources used by the Startup or Shutdown scripts. However, Startup and Shutdown scripts have System privileges on the local computer. This gives Startup and Shutdown scripts access to the local file system and registry.
If you plan to make any configuration or desktop changes with Logon or Startup scripts, remember that changes to the user (or to the HKEY_CURRENT_USER hive of the local registry) should be made in Logon scripts. Changes to the computer (or to the HKEY_LOCAL_MACHINE hive of the local registry) should be made in a Startup script.
A batch file Logon script can connect drives to network shares, connect to shared printers, and run command line utilities. Anything you can do at a command prompt can be done in a batch file. For example, a batch file Logon script that maps a drive to a network share and connects to a printer could be similar to below:
net use H: \\MyServer\MyShare
net use LPT1: \\MyServer\MyPrinter
However, a batch file by itself cannot use ADSI to retrieve information from Active Directory. Unless you use a third party utility, there is no way to determine group membership. One third party tool that does provide the ability to check group membership is KiXtart. The Windows NT resource kit also provides the utility IfMember, which can be used to test for group membership in a batch file. However, IfMember only works on clients with NT or above.
The above discussion applies to networks with Active Directory. The Domain Controllers can be Windows 2000 Server, Windows Server 2003, or Windows Server 2008 and the domain can be at any functional level. However, Logon scripts can also be used in NT domains. The default location for Logon scripts on the PDC or BDC in NT domains is:
The Logon script is assigned on the Profile tab of the user management tool. The corresponding user attribute exposed by the WinNT provider is "loginScript".
The Logon script can be a batch file, command file, or VBScript, with the same restrictions as discussed above with regard to the client operating system. However, since the NT SAM account database is not LDAP compliant, a VBScript program cannot use the LDAP provider. VBScript Logon script programs in NT domains must use the WinNT provider.
Original article: http://www.rlmueller.net/LogonScriptFAQ.htm#How%20do%20I%20setup%20logon%20scripts%20in%20a%20domain%20with%20Active%20Directory