quenga.net - windows & application deployment – remote management – scripting & automation – and more…

Scripts/Other

January 28, 2009

Automatic Log on to Windows

Tags: ,

Log on to Windows (NT and above) Automatically
I have used this on; XP and Vista (all service packs)

There are two processes depending whether or not the computer is part of a domain.

For a domain computer you need to modify the registry.

1. Open the registry; Run regedit

2. Navigate to following registry key:

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon

Note: If any of the following values are not present you must add them.
To add a value; Edit > New > String Value
Enter the value name and data

3. Enter the domain in; DefaultDomainName

4. Enter the username in; DefaultUserName

5. Enter the password in; DefaultPassword

6. Change the value data for AutoAdminLogon entry to 1.
Note: 1 is True and 0 is false

7. Change the value data for ForceAutoLogon entry to 1.

8. Additionally you can; Enter domain in; AltDefaultDomainName

9. Additionally you can; Enter username in; AltDefaultUserName
(setting alternate info will disable the SHIFT key override feature, see note below)

After your computer restarts and Windows log on automatically.

This is a scritp that will set all required fields;

@echo off
REG ADD "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogon" /v "DefaultDomainName" /d "%ComputerName%"
REG ADD "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogon" /v "DefaultUserName" /d "user"
REG ADD "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogon" /v "DefaultPassword" /d "password"
REG ADD "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogon" /v "AltDefaultDomainName" /d "%ComputerName%"
REG ADD "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogon" /v "AltDefaultUserName" /d "user"
REG ADD "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogon" /v "AutoAdminLogon" /d "1"
REG ADD "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWinlogon" /v "ForceAutoLogon" /d "1"

If you want to bypass the automatic log on, hold down the SHIFT key after you log off or after Windows restarts.  However, if you complete steps 8 & 9 above this will not work.  The system will automatically log in as this user.

If you’ve set the alternate information you may be able to use another computer and remotely change these settings.  (In regedit just Connect Network Registry)

To disable this feature, navigate to;

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon

and change value data for ForceAutoLogon to 0.
and change value data for AutoAdminLogon to 0.

For a non-domain computer just run a command

1. Run control userpasswords2 (Vista: run netplwiz).

2. Clear the “Users must enter a user name and password to use this computer” check box.

3. In the Automatically Log On window, type the password and Apply changes.

4. Close all Windows.

Information mostly from: http://support.microsoft.com/kb/315231

Sorry, the comment form is closed at this time.