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.

Background: As part an automated testing suite I am building, I need to set up Autologon on my virtual machines 'on demand'. By on demand, I mean that I don't want to necessarily pre-configure my VM or any snapshot to have Autologon set up already, for security reasons and also a huge business case.

My solution so far: I'm copying a script to the guest machine and then using Sysinternals PsExec to execute it. The script is:

reg add "hklm\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v DefaultUserName /t REG_SZ /d myusername
reg add "hklm\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v DefaultPassword /t REG_SZ /d myfakepassword
reg add "hklm\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v DefaultDomainName /t REG_SZ /d mydomain
reg add "hklm\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v ForceAutoLogon /t REG_SZ /d 1
reg add "hklm\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v AutoAdminLogon /t REG_SZ /d 1
reg add "hklm\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoLogonChecked" /f /ve /d 1

Note: I don't believe AutoLogonChecked is required for machines post Windows 2000 but I'm doing it just in case for now. Maybe ForceAutoLogon isn't either, not sure yet.

The Problem: I see PsExec executes this properly and all the values are in the registry, however when I restart the machine, the user isn't automatically logged on...When I run this a second time then restart the machine, the user is finally logged on.

A diff between the registry states shows that the first time I run this, it is missing both the "1" for AutoAdminLogon, and also the DefaultPassword key. The second time I execute it, these values are correctly intact as I intended.

So, what is going on here? Is this expected? This post claims in the end that it really all just works (the problem was that a logoff script was setting off the values). Doesn't seem to work for me however.

Note this seems unique to Windows 7, does not occur in Windows XP

Also note that you don't need PsExec to recreate the issue - just modify the registry yourself

EDIT/update:

  • Login interactively and run script (so, not executing it remotely), logging off automatically logs me back in (so, it works)
  • remotely execute the script in guest when I'm interactively logged in, logging off automatically logs me back in (so, it works)
  • remotely execute the script in guest when with non-interactive session if I log in afterwards (so, interactive now) then back off, it logs me back in (so, it then works)

EDIT/update 2: This only occurs for Win7x86, Win7x64, Win8x64. This does not occur for Windows XP

EDIT 3: I get same behavior using Sysinsternal's Autlogon.exe tool.

share|improve this question
    
After running your script once, What happens if you log off, log on, then reboot? –  Moab Oct 14 '12 at 3:09
    
Can you see my edits above? Note that since I'm executing the script remotely "I" cannot necessarily log off. You have a good question, one that I'm not sure I'll be able to answer unless there's a utility where I can non-interactively log off and log on. –  jJack Oct 14 '12 at 6:15
    
The plot thickens! hmmmm. –  Moab Oct 14 '12 at 16:18
    
I'm really hoping for an answer here so I can sleep at night. I really think this would get the attention it needed if it were on Stack Overflow, may just keep entering dupes on SO until the Admin gives up and lets it fly there –  jJack Dec 2 '12 at 17:20
    
Did you tried it Run as Admin? –  avirk Dec 3 '12 at 15:13
show 5 more comments

migrated from stackoverflow.com Oct 13 '12 at 21:03

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

4 Answers

up vote 1 down vote accepted

Storing login/password in registry in plain text isn't good idea... I want to recommend you look at LogonExpert tool

share|improve this answer
    
I agree. Actually, the whole idea of Autologon isn't a 'good idea' either...Its meant for Kiosk situations where the system is locked down well from user's ability to do anything malicious. In other words, even if they can get to the clear text credentials, the credentials shouldn't take them very far. I've looked at logonexpert before. I believe there was a limitation, but I'll double check. Thanks! –  jJack Feb 18 '13 at 4:40
    
+1 because this actually is the only tool that has worked for me / solved this particular problem. –  jJack Feb 19 '13 at 4:40
add comment

Seems to be something with PsExec.
Read this question and see if any of solutions there helps you:
How do I change automatic logon via Script or Command Line?

share|improve this answer
    
I'll try the reg file approach I suppose. However note that this is not an issue for Winxp –  jJack Dec 7 '12 at 3:31
    
reg file approach results in same behavior: it is missing both the "1" for AutoAdminLogon, and also the DefaultPassword key. If I then logoff, execute the same reg file the same way, then log back in, it is intact as I intended –  jJack Dec 7 '12 at 4:28
    
i was talking about the autologin tool...reg file is going to be same..moreover, try to avoid PsExec..something sounds fishy there...instead try windows startup scripts: serverfault.com/questions/57798/… –  tumchaaditya Dec 7 '12 at 13:09
    
PsExec is not the culprit. Same behavior occurs with it taken out of the picture –  jJack Feb 18 '13 at 4:42
    
PsExec merely runs the file as another user; basically the same as runas but with additional features (run as SYSTEM, run on remote computer). Manually logging in and running as any user would do the same thing. –  Bob Feb 18 '13 at 5:15
add comment

I am having the similar issue but I don't know the reason for that. Here is my problem.

OS: Windows7 Logged in as local administraotr, and installing our software on the machine. At the end of the software installation (i.e. in the post installation) we join the system in to the domain and we will enable the autologin functionality for one specific user. When I restart the machine first time, it automatically logged in to the user specified in the DefaultUserName. When I tried restarting the machine 2nd time, It doesn't login automatically. Then I looked in to the registry entries (winlogon) and saw that "DefaultPassword" entry got deleted and also "AutoAdminLogon" property is set to 0. When I manually change these values and tried restarting, it works but only the first time.

Note: I also tried increasing the count "AutoLogonCount" property and also by deleting this field from the registry but that doesn't help me.

The question now is that, 1. Why the entry "DefaultPassword" is getting deleted? because which in turn turns the AutoAdminLogon property. 2. How to overcome this, I don't want to tell my customer to login with the creditentials when ever the computer is restarted.

Thank you for your reply.

Regards, Saravanan

share|improve this answer
    
You should post as separate question and link with this. Your problem and conditions are much different –  jJack Mar 10 '13 at 3:41
add comment

tahocannan led me to LogonExpert. With LogonExpert, I can install it silently, set up Auto Logon with it, then (remotely) kill windows' LogonUI.exe process, then reboot. The result: automatically logged in. I then immediately uninstall LogonExpert, then execute commands interactively in the guest machine.

I believe killing the native-Windows "LogonUI.exe" process is the key here. Occasionally, I would get the same result with LogonExpert where after setting up Auto Logon, a reboot would not result in being logged in automatically as desired. By ending LogonUI.exe, it forces a re-load of LogonExpert's library. Then the reboot will work

share|improve this answer
add comment

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.