557.54K

Logon Script

1.

Logon Script

2.

What is Logon Script?
• Logon scripts are a set of tasks that will be performed when a user logs on
to a particular computer. These scripts can carry out operating system
commands, set system environment variables, and call other scripts or
executable programs. Some tasks commonly performed by logon scripts
include:
• Mapping network drives
• Installing and setting a user's default printer
• Collecting computer system information
• Updating virus signatures
• Updating software
10.11.2023
Chao GAO
2

3.

How to Set Logon Script?
• Basically there are 2 ways to create a logon script:
• The first way is to do it through the Profile tab of the user properties dialog in
the Active Directory Users and Computers (ADUC).
• The second is done via Group Policy Objects (GPO).
• The 1st method works for all versions of MS Windows. The 2nd method
works only for Windows 2000 and Later.
• If you have both methods enabled, both will take effect. It is better to use
only one method in a network to avoid confussion.
• In Windows Server 2012 or later, it is recommended to use GPO method.
10.11.2023
Chao GAO
3

4.

Creating LS
• The default location for logon scripts is the NETLOGON share, which, by
default, is shared on all Domain Controllers in an Active Directory forest,
and is located in the following folder:
• %SystemRoot%\SYSVOL\sysvol\<domain DNS name>\scripts
• Where %SystemRoot% is usually “C:\Windows” and <domain DNS
name> is the DNS name of the domain, such as “nXgY.local".
• First use notepad to create a batch logon script (such as logon.bat) and
save it on Desktop.
10.11.2023
Chao GAO
4

5.

Copy the Batch File
• To C:\Windows\SYSVOL\sysvol\%youDomain%\scripts
10.11.2023
Chao GAO
5

6.

Choose User
• Choose the right user from the "Active Directory Users and Computers"
• Right-click on the user and "Properties…"-> Profile
10.11.2023
Chao GAO
6

7.

Testing LS
• Logon this user in a client computer.
• Check that logon scripts have been executed. (if you have used "net use"
command to map a network drive, then you should be able to see that this
drive appears in the "Windows Explorer" window).
10.11.2023
Chao GAO
7

8.

Assigning Logon to User Group

9.

Using Group Policy Objects
• There are a few benefits for using GPOs to assign scripts:
• Using GPOs you can assign MORE than one logon script per user, and you can
configure which script runs first.
• Using GPOs you can also assign LOGOFF scripts for users, and even STARTUP
and SHUTDOWN scripts for the computer itself.
• GPOs can be linked to OUs, Site or Domain levels, meaning that with one GPO
you can assign a logon script to many users, or even to all your users, instead
of having to manually adding it to all the user objects in the domain.
• GPOs only work with Windows 2000 and above, meaning that if your
users use older clients such as Windows 95/98 or Windows NT, GPOs
won't work for them.
10.11.2023
Chao GAO
9

10.

The Setting of GPO
• Start "Group Policy Management"
• Create a new GPO in this domain
10.11.2023
Chao GAO
10

11.

Edit the Policy
• Right-click the newly created policy -> "Edit"
10.11.2023
Chao GAO
11

12.

Verify
• Logoff and logon a Windows client.
10.11.2023
Chao GAO
12

13.

GPO for Logon/Logoff Script
• You can also set logon/logoff script in GPO:
• Try to make a logoff script with GPO, when the user logs-off, all the *.bat
files in his U: drive should be deleted.
10.11.2023
Chao GAO
13
English     Русский Правила