Logon scripts

A logon script is a file (normally a .bat) that the PC runs when the user signs in. Scripts live in the domain’s SYSVOL scripts folder, and are assigned to…

A logon script is a file (normally a .bat) that the PC runs when the user signs in. Scripts live in the domain’s SYSVOL scripts folder, and are assigned to each single user from the «Logon script» field of their page (Users). A new domain contains an example one.

The list

The scripts listThe scripts list
The scripts list

The bar shows the title «Logon scripts», the search and the «Add script» (+) button. Each row is a file with its name, size and update date. When you choose a script the detail bar has two buttons:

Button What it does
«Details» the dialog with «Size», «Created» and «Updated»
«Delete» deletes the file, after the confirmation (see below)

The fields

Field What it means Typical value
«Filename» only at creation, then it cannot be changed. Only the name, without path separators. Letters, digits, ., -, _, up to 128 characters, with an alphanumeric first character logon.bat
«Content» the script’s text, in a large text field see the examples

A .bat or .cmd file is saved in the form Windows reads: CRLF line endings and OEM 850 encoding, so accented letters are fine and the € symbol is not. If the content has characters that encoding cannot represent, the save is refused and the console lists them («A .bat or .cmd file cannot contain: …»). Other file types are saved as you write them, in UTF-8. Files are written as executable.

Press «Create script» (for a new one) or «Save» (for an existing one) at the bottom right.

Assigning a script to a user

The script does not apply by itself: it must be chosen in the user’s page, «Logon script» field (the list contains the scripts of this page; «(none)» for none). At the next sign-in to Windows the PC runs it.

Deleting a script

«Delete» asks for confirmation. If no user has it: «Delete this script? No user has it.». If users have it, the confirmation lists them: «Delete this script? 3 users have it (jgreen, jbrown, pblack): it is taken off their accounts and no longer runs at their next sign-in.» If Atlas cannot take it off the users, the script is not deleted and the console says so («The script was not deleted: it could not be taken off the users who have it.»).

Example: a script that connects the common folder

You want to connect S: to the common folder for everyone who has this script.

  1. Open Active Directory → Logon scripts and click «Add script».

  2. In «Filename» write logon.bat.

  3. In «Content» write:

    @echo off
    net use S: \\atlas\common /persistent:no
  4. Click «Create script».

Check. The script appears in the list with its size; opening «Details» you see the dates. It has no effect until you assign it to a user (next example).

If something goes wrong. «Invalid filename. Use letters, digits, ‘.’, ‘-’, ‘_’ (no slashes).» means you wrote a path or a space. «A script with this filename already exists.» asks for another name.

Example: assigning the script to a user

  1. Open Active Directory → Users and choose jgreen.
  2. In the «Features» block, «Logon script» field, choose logon.bat.
  3. Click «Save».
  4. Have the user sign out and back in to Windows.

Check. After the sign-in, drive S: appears in File Explorer for jgreen (if jgreen has access to the common share).

If something goes wrong. If the drive does not appear, check that the PC is in the domain, that jgreen really has the permission on the folder and that the sign-in is new (the script does not run again for a sign-in that is already open).

Example: editing a script and removing one that is no longer used

You change the drive letter and remove a script that is no longer needed.

  1. Open logon.bat, change S: to T: in the «Content» and click «Save».
  2. Open old.bat and click «Delete». The dialog lists the three users who have it.
  3. Confirm with «Delete».

Check. The message is «Script deleted and taken off 3 users.». Opening one of those users, the «Logon script» field is «(none)».

If something goes wrong. If the deletion fails with “it could not be taken off the users”, the directory did not answer in full: the script is still there and the users still have it; try again.

Limits and pitfalls

  • The script is per user, not per group or per computer: to assign it to twenty people you choose it twenty times. For a group setting use group policies.
  • The name cannot be changed: to rename, create a new file, assign it and remove the old one.
  • A .bat file with characters outside the OEM 850 encoding cannot be saved.
  • In a Windows domain (coexistence) the entry does not exist.

For the technician The files are in sysvol/<realm>/scripts and Windows reads them from \\<domain>\NETLOGON. The «Logon script» field writes the user’s scriptPath attribute. SYSVOL permissions (read for authenticated users) are checked every day by Atlas and repaired by themselves; the «Reset the SYSVOL permissions» button is in System → Settings → File sharing.


LET’S TALK INFRASTRUCTURE

Control starts with a conversation.

Tell us about your infrastructure. Let’s start with what you actually need.

Talk to an engineer