ProblemYou want to set the login script for a local or domain user account. SolutionThe following solutions describe how to set the login script for a local user account on a system. Using a graphical user interface
Using a command-line interfaceThe following command sets the login script for a local user: > net user <UserName> /scriptpath:<ScriptName> <ScriptName> should be the relative path of the script from the NETLOGON share. Using VBScript' This code sets the login script for a local user ' ------ SCRIPT CONFIGURATION ------ strComputer = "<HostName>" strUser = "<UserName>" ' e.g. administrator strLoginScript = "<ScriptName>" ' e.g. login.vbs ' ------ END CONFIGURATION --------- set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",user") objUser.LoginScript = strLoginScript objUser.SetInfo WScript.Echo "Set login script for " & objuser.Name The following solutions describe how to set the login script for a domain user account. Using a graphical user interface
Using a command-line interfaceThe following command sets the login script for a domain user: > net user <UserName> /domain /scriptpath:<ScriptName> The following command can also set the login script for a domain user: > dsmod user "<UserDN>" -loscr <ScriptName> <ScriptName> should be the relative path of the script from the NETLOGON share on the DCs. Using VBScript' This code sets the login script for a domain user ' ------ SCRIPT CONFIGURATION ------ strUserDN = "<UserDN>" ' e.g. cn=administrator,cn=users,dc=rallencorp,dc=com strScriptPath = "<ScriptName>" ' e.g. login.vbs ' ------ END CONFIGURATION --------- set objUser = GetObject("LDAP://" & strUserDN) objUser.Put "scriptPath", strScriptPath objUser.SetInfo WScript.Echo "Login script set for " & objUser.Name DiscussionA login script can be a Windows batch file (.bat extension) or anything supported by Windows Scripting Host on the system that runs the script. By default, this includes VBScript and JScript. The login script setting you configure in a user's profile must contain the name of the script and the relative path from the NETLOGON share. When a user (with a local user account) logs into a system, a check is done to see if there is a login script defined for that user let's say that login.vbs has been configured. The system then attempts to run \\localhost\NETLOGON\login.vbs. By default, the NETLOGON share does not exist on Windows XP systems. See Recipe 8.23 for more on how to create a share. You can point the NETLOGON share to any directory on the system. You can also use subdirectories under the NETLOGON share. If the NETLOGON share is pointing to c:\Scripts and we created a subdirectory under that called Local, then we'd need to configure my local user's login script setting to Local\login.vbs. See AlsoMS KB 258286, "HOW TO: Assign a Logon Script to a Profile for a Local User in Windows 2000," and MS KB 315245, "How to Assign a Logon Script to a Profile for a Local User" |