Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have 2 accounts. How would I go about automatically logging in to one of the accounts when I start the computer up? So, it would not give the user the option to log into the other account right off the bat.

Would I use a batch file and use Group Policy to run it? If so, what command is used to log in from a batch file?

share|improve this question

migrated from stackoverflow.com Sep 16 '12 at 1:10

This question came from our site for professional and enthusiast programmers.

    
I was going to post it there, but my question is more programming-related. –  Isaiah Bugarin Sep 15 '12 at 22:04
    
    
@JoachimIsaksson Thank you, but I really need a way to do it via a startup script, as I only want it to automatically log in if the screen resolution is 1920x1080, which requires a startup script. –  Isaiah Bugarin Sep 15 '12 at 22:16

1 Answer 1

Try this:

set LOGON_KEY=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

rem check screen resolution here, if check succeeds:
rem set RESOLUTION_OK=y

if /i "%RESOLUTION_OK%"=="y" (
  reg add "%LOGON_KEY%" /v AutoAdminLogon /t REG_SZ /d 1
  reg add "%LOGON_KEY%" /v DefaultUserName /t REG_SZ /d USER
  reg add "%LOGON_KEY%" /v DefaultDomainName /t REG_SZ /d DOMAIN
  reg add "%LOGON_KEY%" /v DefaultPassword /t REG_SZ /d PASS
) else (
  reg add "%LOGON_KEY%" /v AutoAdminLogon /t REG_SZ /d 0
  reg delete "%LOGON_KEY%" /v DefaultUserName
  reg delete "%LOGON_KEY%" /v DefaultDomainName
  reg delete "%LOGON_KEY%" /v DefaultPassword
)

It should enable auto-logon for DOMAIN\USER with the password PASS. To avoid storing credentials in a script, you could manually create and populate the values DefaultUserName, DefaultDomainName and DefaultPassword, and only toggle the AutoAdminLogon value.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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