Logon Scripting - A Powerful, Underutilized Tool

Archived content. No warranty is made as to technical accuracy. Content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Windows Tips & Secrets
1998 PLATINUM technology, Inc.

Reprinted with permission from Platinum Technology, Inc.

If you have a background in NetWare, then you are probably familiar with logon scripts. They are available in Windows NT as well. One of the benefits to using logon scripts with Windows 95 and Workstation 4.0 clients, is you have greater administrative control. Another benefit is that it can augment connectivity troubleshooting. Often, using logon scripts will eliminate errors you may have had connecting to a shared resource using the Windows GUI.

The logon script feature is not actually a script. It is a hook in the User Environment Profile. The Logon script name can be a batch file or an executable file. The batch files are commonly simple, comprising a set of NET USE statements that map drives and printers. However, they can be as complicated as you need them to be. You can call other batch files or set up any conditionals that you need. You may want to add a NET TIME command to synchronize all of your clients to the server.

You can use these variables in your logon script:

%Homedrive%: The drive letter of the local workstation.

%Homepath%: The user's home directory path.

%Homeshare%: The share name of the user's home directory.

%Os%: The workstation operating system.

%Processor_architecture%: The Processor type (e.g., x86)

%Processor_level%: The processor lever of the workstation (3, 4 or 5 for an x86).

%Userdomain%: The user's Domain.

%Username%: The user name.

Once you've created your logon script, copy it to your NETLOGON shared directory (usually WINNT\System32\Repl\Import\Scripts). If you have multiple BDCs, you should set up replication, so that the server that authenticates the logon has a copy of the logon script. You can name it anything you want. If you are assigning scripts to specific groups, you may want to match the name of the batch file to the group, or place the file in a relative path in the NETLOGON share (Accounting\logon.bat).

Next, you need to set up the User Environment Profile.

  • Logon with Administrator privileges and Start User Manager for Domains.

  • Select one or more Users.

  • Click UserPropertiesProfile.

  • In Logon Script Name, type the name of the logon script program (logon.bat). You may include a relative path (Accounting\logon.bat). Click OK.

The next time the user logs on to the network, the logon script will execute at startup.

One good way to use this technique is for troubleshooting Windows drive mapping. If a client has had trouble maintaining drive mappings (for instance they don't have errors on startup, but the resource becomes unavailable later in the day), then disconnect all drives and map with logon scripts.

  • Open Explorer and select ToolsDisconnect Network Drive.

  • Select all the drives, and click OK.

  • Create a logon script to map all of the same drives using NET USE and make the script available to the User according to the instructions above.

We have found that logon scripts greatly enhance the administrator's role . You have more control over your user's environment and are able to establish and maintain easily updated standards.

Additional Information

For more information, go to the Platinum Technology, Inc. web site at: http://www.cai.com/.

We at Microsoft Corporation hope that the information in this work is valuable to you. Your use of the information contained in this work, however, is at your sole risk. All information in this work is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Microsoft Corporation. Microsoft Corporation shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.