Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autologin *Still* doesn't work. #318

Closed
Templvr21 opened this issue Jul 18, 2018 · 21 comments
Closed

Autologin *Still* doesn't work. #318

Templvr21 opened this issue Jul 18, 2018 · 21 comments
Assignees
Labels
Invalid / Not Issue / No repro / Not Implementing NO RELEASE NOTES Should not be included in the release notes - not enhancing or fixing end product
Milestone

Comments

@Templvr21
Copy link

I have been testing out a Boxstarter script on a local Hyper-V VM but no matter what I do I can't seem to get the machine to automatically log in after restarting. I've tried writing the switch as "-Credential Get-Credential userName", "-Credential (Get-Credential userName)" (as recommended by another user experiencing this issue) and passing the credentials to the switch through a variable, as "-Credential Get-Credential $creds" but I still have to enter my password each time it restarts. I also tried running the Enable-BoxstarterVM command, but it prompted me to install the Hyper-V Powershell module with the following command that failed:

Install-windowsfeature -name hyper-v -IncludeManagementTools

Any help is appreciated; thanks.

@mwrock
Copy link
Member

mwrock commented Jul 18, 2018

try -Credential $creds. If you have already save creds to a variable there is no need to use Get-Credential which will prompt you.

@Templvr21
Copy link
Author

Thank you for the response. Sorry; that's what I meant—I'll enter Install-BoxstarterPackage -PackageName name -Credential $creds after already creating a PSCredential object and storing the memory ID in $creds. In all three instances I described in my initial comment, as soon as the package finishes downloading, the computer will either restart or begin installing the package, depending on whether or not I've attempted to run the script previously, usually restarting when I run the Install-BoxstarterPackage command the first time. When I run the command the first time, Boxstarter with download the package and restart; once the computer boots up, the login screen appears prompting me for a password. I've also checked that the VM I'm running the command on has the latest version of Boxstarter, and uses the latest version of Chocolatey contained with the Boxstarter software.

@pauby pauby added the 0 - _Triaging Issue is accepted, but a milestone has yet to be added for the issue label Aug 5, 2018
@pauby
Copy link
Member

pauby commented Aug 5, 2018

Is this maybe related to #1 ?

@yodurr
Copy link

yodurr commented Aug 28, 2018

I'm having the same issue on Windows 10 where the reboot happens and then it sits on the login screen without logging in. When I manually log in I can see Boxstarter already running.

@pauby
Copy link
Member

pauby commented Aug 28, 2018

@yodurr is this also on Hyper-V?

@yodurr
Copy link

yodurr commented Aug 28, 2018

Yes, on Hyper-V. The particular scripts I'm running are on aka.ms/devsetup
But I'm also seeing this in non Hyper-V scenarios.

We need to dig into this further to identify root cause.

@dominikgeimer
Copy link

I have the same problem. Hyper-V on Windows 10 with a Windows 10 virtual machine. After first reboot it is stuck at the login screen.

@ctmcisco
Copy link

ctmcisco commented Sep 10, 2018

I have done demos with this functionality working with Windows 10 Pro 64bit VM. When did this change, as Autologin was working. Could this be something stemming from Windows 1803. Going to try 1703 and report back.

@ctmcisco
Copy link

ctmcisco commented Sep 10, 2018

In 1703, Boxstarter commits a reboot and on reboot I have to manually login. But script continues to run and also prompts me to provide a password, where in 1803 I dont get this prompt

image

regardless on the next run I still had to provide the password.

I initially started the script from 32bit powershell

@ctmcisco
Copy link

ok giving up for now I sent all the way back to Windows 10 1511 and still can not get the OS to autologin. Something must have changed in Boxstarter in 2.11 although I checked my at my recorded demo it I used 2.11 on 1803 and was working.

@ctmcisco
Copy link

So I kept digging further. I never checked the registry for this as the autologin process was working at some point.

Here is the local user account SID:

image

Here it the Autologin Registry key and points to the correct SID:

image

What I don't see are the following Registry keys:

DefaultUserName
DefaultPassword
AutoAdminLogon

Which I assume are for hard coded credentials only which is not the intention here for Boxstarter.

If the correct SID is being configured could the issue be stemming from the encrypted string for the password?

@ctmcisco
Copy link

ctmcisco commented Sep 11, 2018

ok this has to be a Windows 10 issue I haven't seen until now

I used this settings without even installing Boxstarter:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"DefaultUserName"="USERNAME"
"DefaultDomainName"="DOMAIN"
"DefaultPassword"="PASSWORD"
"AutoAdminLogon"="1"

The autologin mechanism seems broken in my machine. I may have to rebuild and try again.

@pauby
Copy link
Member

pauby commented Sep 17, 2018

I've just tried this with a vagrant VB VM and it works fine.

image

Going to test the exact same setup on a Hyper-V VM and will see what that gives me.

@fwinkelbauer
Copy link

I've added the above registry entries to a fresh Windows Server 2016 hyper-v image:

hyper-v

I still have to login after rebooting the machine.

@fwinkelbauer
Copy link

Boxstarter can keep executing a script/package, even if the autologin is not working. Here's my experiment:

Create a new Boxstarter package based on this very simplistic file reboot.ps1:

Invoke-Reboot

Which can be turned into a package with a local copy of Boxstarter by running:

Import-Module 'C:\ProgramData\Boxstarter\Boxstarter.Chocolatey'
New-PackageFromScript .\reboot.ps1 my.reboot
Copy-Item $Boxstarter.BaseDir . -Recurse

Next I copied over the .\Boxstarter folder to my Windows Server 2016 Hyper-V image. If we now start the process by running:

.\Boxstarter\Boxstarter.bat my.reboot

The machine keeps rebooting, even if no autologin happens.

It seems to me that the user is logged in, but the machine is just locked (similar to how you lock a machine by pressing Win + L).

@pauby pauby added Bug Issues where something has happened which was not expected or intended Up For Grabs Priority_HIGH Issues that are considered to be a high priority to get fixed 0 - Backlog Issue is accepted, but is not ready to be worked on or not in current sprint and removed 0 - _Triaging Issue is accepted, but a milestone has yet to be added for the issue labels Mar 19, 2019
@9denis
Copy link

9denis commented Apr 26, 2019

I think, I know the issue with -Credential $creds not working for local installation (i.e., if you are specifying a different username and password in $creds).

Install-BoxStarterPackage invokes Invoke-Locally function for local installation of packages. Invoke-Locally only keeps password and gets rid of the Credentials from $PSBoundParameters, before passing it onto Invoke-ChocolateyBoxstarter. So, the username supplied via $creds is lost.

Then Cleanup-BoxStarter function queries the current user session for username and uses that for AutoLogon setup. So, if you try to execute Install-BoxStarterPackage under a different user by specifying -Credential $creds, its never going to work.

I am trying to run this as part of "userdata" on AWS and it doesn't work, because userdata is executed under SYSTEM account. And the $creds that I am passing are for local admin account.

See the code from Install-BoxStarterPackage below:

function Invoke-Locally {
    param(
        [string[]]$PackageName,
        [Management.Automation.PsCredential]$Credential,
        [switch]$Force,
        [switch]$DisableReboots,
        [switch]$KeepWindowOpen,
        [switch]$DisableRestart,
        [string]$LocalRepo
    )
    if($PSBoundParameters.ContainsKey("Credential")){
        if($Credential -ne $null) {
            $PSBoundParameters.Add("Password",$PSBoundParameters["Credential"].Password)
        }
        $PSBoundParameters.Remove("Credential") | Out-Null
    }
    else {
        $PSBoundParameters.Add("NoPassword",$True)
    }
    if($PSBoundParameters.ContainsKey("Force")){
        $PSBoundParameters.Remove("Force") | Out-Null
    }
    $PSBoundParameters.Add("BootstrapPackage", $PSBoundParameters.PackageName)
    $PSBoundParameters.Remove("PackageName") | Out-Null

    $record = Start-Record 'localhost'
    try {
        Invoke-ChocolateyBoxstarter @PSBoundParameters
    }

@mwallner mwallner added this to the v2.13.0 milestone Jun 4, 2019
@lukebal
Copy link

lukebal commented Jul 10, 2019

I thought I had this problem too, but then realized I was using an "Enhanced Session" with my Hyper-V guest. I use this by default (clipboard redirection FTW), and didn't even think to disable this.
As soon as I disabled it, the autologin functionality worked when the Install-Boxstarterpackage was passed with a correct -Credential parameter.
This makes sense, as the Enhanced Session in Hyper-V is basically an RDP session, and autologin would only be an interactive login.

@pauby
Copy link
Member

pauby commented Jul 21, 2019

I've been trying to look at this for some time now and finally got to put some time into it and thought I'd pass on what I found. I've been using Hyper-V Vagrant environments to test this out. Before I started I made sure:

  • The box did not autologin on bootup;
  • I was using the Basic Session (note the comments from @lukebal above;
  • The box only had Chocolatey and Boxstarter installed (I used Chocolatey to install Boxstarter);
  • I was logged in as the Vagrant user (which is the same user I give Boxstarter the creds for);

I used a very simple script below to kick it off the reboots on each machine (I am also logged in

Remove-Item -Path 'c:\vagrant\reboot.flag' -ErrorAction SilentylContinue
$secpasswd = ConvertTo-SecureString "vagrant" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("vagrant", $secpasswd)
Install-BoxstarterPackage -PackageName c:\vagrant\tests\boxstarter-test.ps1 -Credential $mycreds

c:\vagrant\tests\boxstarter-test.ps1 is just something that forces a reboot (once):

if (-not (test-path 'c:\vagrant\reboot.flag')) {
    New-item 'c:\vagrant\reboot.flag' -ItemType file
    Invoke-Reboot
}

choco install putty

I went all the way back to Server 2008R2 (PowerShell 3) just for belts and braces. Here are the results:

  • Windows Server 2008 R2 - Autologin?: Yes
  • Windows Server 2012 R2 - Autologin?: Yes
  • Windows Server 2016 - Autologin?: Yes
  • Windows Server 2019 (Version 1809 Build 17763.503) - Autologin?: Yes
  • Windows 10 Enterprise (Version 1709 Build 16299.125) - Autologin? : Yes
  • Windows 10 Enterprise (Version 1803 Build 17134.1) - Autologin?: Yes
  • Windows 10 Enterprise (Version 1809 Build 17763.1) - Autlogin?: Yes
  • Windows 10 Enterprise (Version 1903 Build 18362.239) - Autologin?: Yes

So from the point of view of giving Boxstarter the credentials of the currently logged in user and getting it to reboot into and auto login, I can't reproduce the issue.

One thing to note is that Hyper-V will default to opening an Enhanced Session on OS's that have Integration Services installed (from memory that is Server 2012 R2 onwards) and this is like an RDP session so is not auto logged in. What you need to do is make sure you are checking the Basic Sessions (which is effectively the console session). Some people above have mentioned when they log in Boxstarter is already running and this sounds like this is what is happening? I don't want to teach people to suck eggs but I just wanted to make sure it was clear.

@pauby
Copy link
Member

pauby commented Jul 21, 2019

@9denis Invoke-Locally does only provide the option to specify a password. It then calls Invoke-ChocolateyBoxstarter and the parameters for that only accept a password. Invoke-Boxstarter is then called and again there is no username parameter, only password. So from all of that it looks like Boxstarter, by design, only uses the currently logged on account for autologin.

I am happy to br proven wrong as I'm only looking at the code. Is there anything that says otherwise?

@pauby
Copy link
Member

pauby commented Oct 7, 2019

I've run a few of the scripts from https://github.com/microsoft/windows-dev-box-setup-scripts onto a Server 2016 a Windows 10 1903 Hyper-V Vagrant box and cannot duplicate this issue. When logged in as a Basic Session the boxes reboot when they should and log back in again (over multiple reboots depending on the script).

To reiterate what has been said in previous comments, when connecting to Hyper-V you must connect as a Basic Session for the box to autologin and you to see it. If you use an Enhanced Session you are basically using RDP to the box so it will autologin and run the script but you won't see it until you login yourself.

So I cannot reproduce this issue. As there has been no update from anybody else on this issue after my last comment I'm going to go ahead and close this. If there is anymore info on this in future I'm happy to open it again.

@pauby pauby closed this as completed Oct 7, 2019
@pauby pauby added Invalid / Not Issue / No repro / Not Implementing and removed 0 - Backlog Issue is accepted, but is not ready to be worked on or not in current sprint Bug Issues where something has happened which was not expected or intended Priority_HIGH Issues that are considered to be a high priority to get fixed Up For Grabs labels Oct 7, 2019
@pauby pauby modified the milestone: v2.13.0 Oct 7, 2019
@karoonlatifi
Copy link

Thank you @lukebal after i changed Hyper-V settings to "Basic Session" and starting the virtual machine with the administrator account, the autologin with the given Credentials worked. I'm happy too! This problem costed me really lots of time.

Actually I had the problem only with VM. On a real machine boxstarter worked with no problem.

@pauby pauby added the NO RELEASE NOTES Should not be included in the release notes - not enhancing or fixing end product label Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Invalid / Not Issue / No repro / Not Implementing NO RELEASE NOTES Should not be included in the release notes - not enhancing or fixing end product
Projects
None yet
Development

No branches or pull requests