Set user for auto logon on windows via batch script
What I want to do is, to set one of 2 users as default user and auto logon. After some research I found how to do it via gui:
- Windows Key + R
- Enter
control userpasswords2
- Select user that you want to be default during auto logon
- Untick
Users must ...
Something like that
But, there are about 70 computers in room that waits for user to select one of 2 user accounts: "admin" and "user1" before start. I want to do it not via GUI but with the help of simple .cmd
or .bat
script. is that possible? How to set user1
as default account and disable logon user selection screen with bat file? Please help.
BTW, the windows I use is XP
Solution 1:
You can set these values in registry:
Enable Auto Logon:
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1
Set username for logon:
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d youruser
Set domain if your pc is in domain:
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t REG_SZ /d yourdomain
Set users password:
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d yourpassword
Set how many times it shoud logon automatically (0 for infinite):
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoLogonCount /t REG_DWORD /d 0
Copy these in setlogon.bat file and you have your script.
Solution 2:
You should add /f
to the end of each of those REG ADD
commands, to suppress the confirmation question if the key already exists.