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:

  1. Windows Key + R
  2. Enter control userpasswords2
  3. Select user that you want to be default during auto logon
  4. Untick Users must ...

Something like that

enter image description here

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


You can set these values in registry:

  1. Enable Auto Logon: reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1

  2. Set username for logon: reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d youruser

  3. Set domain if your pc is in domain: reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t REG_SZ /d yourdomain

  4. Set users password: reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d yourpassword

  5. 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.

  • WHat if you have no pass? – user978733 Dec 4 '12 at 7:33
  • 1
    Never tried that, but I suppose that empty DefaultPassword, should work. – week Dec 4 '12 at 19:04
  • This doesn't work for me. Also, putting your password in cleartext in the registry seems really really wrong. When using control userpasswords2, the password is hashed somewhere, and the "DefaultPassword" registry key isn't added. Does this really work for anyone? – DanielSmedegaardBuus Nov 3 '13 at 14:49
  • Yep, It's working, at least on Windows (2k, XP, 7), I've used this over the years for automatic deployment. And yes it's not wise for ordinary use. Well, hashed somewhere means registry:) and no it's not hashed, it's encrypted and stored in LSA. But it's still in registry under `HKLM\security`. Try this app to see all stored passwords there. It's not safe either. – week Nov 4 '13 at 1:02
  • Step 5 is wrong. Setting it to 0 disables the autologon immediately after a restart and deletes the other registry keys. Remove that registry key and it works correctly. – Roemer Feb 7 '17 at 9:29

You should add /f to the end of each of those REG ADD commands, to suppress the confirmation question if the key already exists.

  • 2
    Hello! Welcome to Super User! This doesn't not answer OP's question, and should be a comment. Once you gain enough reputation on the site, you'll be able to comment on answers and questions. – rahuldottech Sep 15 '18 at 5:05
  • Welcome to superuser: This does not answer the question. An answer has been accepted which would mean that it works so if your answer (comment) is to be useful you will need to add detail as to why it is correct. Please take a couple of minutes and read:- How to Answer, again welcome to superuser.Thankyou – mic84 Sep 15 '18 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.