Problem
It turns out that because AutoLogonCount is set to 1, on logon it decrements it to zero. On logoff and reboot when Windows 7 sees the AutoLogonCount set to zero it deletes the keys "AutoAdminLogon", "AutoLogonCount", and "DefaultPassword" from the registry. Those same values I had just set for the ViewUser.
Solution
The easy solution is easy, I just have to add a command to delete the AutoAdminLogon key from the registry my self. Then Windows never goes back and cleans up the Auto Logon Registry keys that where just set.
<AutoLogon> <Password> <Value>password</Value> <PlainText>true</PlainText> </Password> <Domain>.</Domain> <Enabled>true</Enabled> <LogonCount>1</LogonCount> <Username>Administrator</Username> </AutoLogon>
This is how it will look in the sysprep unattended file to set the autologon after the administrator autologon.
<SynchronousCommand wcm:action="add"> <CommandLine>cmd /c reg.exe delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v AutoLogonCount</CommandLine> <Description>Remove AutoLogonCount so that other autologon settings stay</Description> <Order>18</Order> <RequiresUserInput>false</RequiresUserInput> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <CommandLine>cmd /c reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v DefaultDomainName /t Reg_SZ /d .</CommandLine> <Description>Set default Domain for autologon</Description> <Order>19</Order> <RequiresUserInput>false</RequiresUserInput> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <CommandLine>cmd /c reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v DefaultUserName /t Reg_SZ /d ViewUser</CommandLine> <Description>Set default UserName for autologon</Description> <Order>20</Order> <RequiresUserInput>false</RequiresUserInput> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <CommandLine>cmd /c reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v DefaultPassword /t Reg_SZ /d password</CommandLine> <Description>Set default Password for autologon</Description> <Order>21</Order> <RequiresUserInput>false</RequiresUserInput> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <CommandLine>cmd /c reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /f /v AutoAdminLogon /t Reg_SZ /d 1</CommandLine> <Description>Set AutoLogon to enabled </Description> <Order>22</Order>
By the way, for permanent autologon with encrypted password you can use Logonexpert tool
ReplyDeletehi,
ReplyDeletewhere should i put that script ?
By Script do you mean where do you put sysrep unattended file? If so i put mine in "c:\Windows\System32\sysprep" folder and then put a SynchronousCommand in to delete the file as it contains passwords.
ReplyDeletewhat registry key should i delete if i don't want to use "Autologin" after sysprep process ?
ReplyDeleteThanks
If you don't want sysprep to autologin; just don't include that part in your unattended file. I think you may be missing a step of this. if you want email me i'll try to help you off line.
ReplyDeleteChristowlesblog@gmail.com
What if I want to autologon twice? once to change the PC name and again to join the domain...but after that, not autologon? Just set the autologon to 2 in the unattend.xml file? according to the Help, it resets at each reboot...
ReplyDeleteI ran into the same problem. In discoverd that removing the autologoncount from the registry is not enough, it still counted down.
ReplyDeleteWhat i did to solve the problem is after making the answerfile with wsim, was removing the counter afterwards from the xml by hand. This can't be done from wsim.
Now it automatic logs on until i remove the logon account by script or hand
Best regards,
BB2000
This looks sweet, and the Vmware document you made was absolutely brilliant.
ReplyDeleteHow does your complete autounattend.xml looks like? I got into the same issues as you with autologin after sysprep.
Mark
You made my day, Chris!!
ReplyDeleteThank you very much!
Awesome! Was having the same exact problem. Thank you for posting the solution!!
ReplyDelete