At a client that still runs Windows Server 2003 (despite the fact that it is in the extended support phase now), I needed to enable automatic logon (one of the tools they run sometimes fails when nobody is logged on).
This was a bit more tricky than just reading [WayBack] How to turn on automatic logon in Windows (now at How to turn on automatic logon in Windows) and following these steps:
To use Registry Editor (
Regedt32.exe
) to turn on automatic logon, follow these steps:
- Click Start, and then click Run.
- In the Open box, type Regedt32.exe, and then press ENTER.
- Locate the following subkey in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon- Double-click the DefaultUserName entry, type your user name, and then click OK.
- Double-click the DefaultPassword entry, type your password, and then click OK.NOTE: If the DefaultPassword value does not exist, it must be added. To add the value, follow these steps:
- On the Edit menu, click New, and then point to String Value.
- Type DefaultPassword, and then press ENTER.
- Double-click DefaultPassword.
- In the Edit String dialog, type your password and then click OK.
NOTE: If no DefaultPassword string is specified, Windows automatically changes the value of the AutoAdminLogon key from 1 (true) to 0 (false), disabling the AutoAdminLogon feature.
- On the Edit menu, click New, and then point to String Value.
- Type AutoAdminLogon, and then press ENTER.
- Double-click AutoAdminLogon.
- In the Edit String dialog box, type 1 and then click OK.
- Quit Registry Editor.
- Click Start, click Shutdown, and then type a reason in the Comment text box.
- Click OK to turn off your computer.
- Restart your computer. You can now log on automatically.
Since this depends on some registry settings, you need to make sure they are actually set.
And logging on as someone else will reset the DefaultUserName registry setting.
The article points to another article on “AutoAdminLogon looses DefaultUserName” to solve this using REGINI (and optionally REGDMP which can provide sample output for REGINI), but there is a much easier solution using RegEdit which – as Rob van der Woude points out – can be used unattended as well (besides: REGDMP cannot be downloaded any more, and REGINI requires an additional download).
This is how to do force the DefaultUserName
to be reset after logon using RegEdit:
- Open an explorer Window in “
%ALLUSERSPROFILE%\Start Menu\Programs\Startup
“ - Create a batch file “
run-RegEdit-DefaultUserName.bat
” there with this content:
regedit /s Administrator-DefaultUserName.reg
- Create a text file “
Administrator-DefaultUserName.reg
” in the same directory with content like this:Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] "DefaultUserName"="Administrator"
Replace “Administrator
” with the username you are actually using.
–jeroen