In Windows 10, there’s a feature that allows users to automatically log in without entering a password. This is particularly useful in scenarios where a machine needs to boot up and run an application without human intervention. Here’s how to enable this feature using PowerShell and the Windows Registry:
With ForceAutoLogon
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
$DefaultUsername = "Compte"
$DefaultPassword = "Password"
$DefaultDomain = "Domaine.local"
Set-ItemProperty -Path $RegPath -Name "AutoAdminLogon" -Value "1" -Type String
Set-ItemProperty -Path $RegPath -Name "DefaultUsername" -Value "$DefaultUsername" -Type String
Set-ItemProperty -Path $RegPath -Name "DefaultDomainName" -Value "$DefaultDomain" -Type String
Set-ItemProperty -Path $RegPath -Name "ForceAutoLogon" -Value "1" -Type String
Set-ItemProperty -Path $RegPath -Name "DefaultPassword" -Value "$DefaultPassword" -Type String
With AutoLogonCount
$winlogonPath = "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
# Définir les clés de registre pour l'auto-login sans utiliser de variables
Set-ItemProperty -Path $winlogonPath -Name "AutoAdminLogon" -Value "1" -Type String
Set-ItemProperty -Path $winlogonPath -Name "DefaultUserName" -Value "david" -Type String
Set-ItemProperty -Path $winlogonPath -Name "DefaultDomainName" -Value "monlab" -Type String
Set-ItemProperty -Path $winlogonPath -Name "DefaultPassword" -Value "Password1" -Type String
Set-ItemProperty -Path $winlogonPath -Name "AutoLogonCount" -Value 2147483647 -Type DWord
Without AutoLogonCount and Without ForceAutologon
This solution is similar to AutoLogonCount but without a limit
$winlogonPath = "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
# Définir les clés de registre pour l'auto-login sans utiliser de variables
Set-ItemProperty -Path $winlogonPath -Name "AutoAdminLogon" -Value "1" -Type String
Set-ItemProperty -Path $winlogonPath -Name "DefaultUserName" -Value "david" -Type String
Set-ItemProperty -Path $winlogonPath -Name "DefaultDomainName" -Value "monlab" -Type String
Set-ItemProperty -Path $winlogonPath -Name "DefaultPassword" -Value "Password1" -Type String
AutoLogonCount vs ForceAutoLogon
The AutoLogonCount
and ForceAutoLogon
registry keys both play roles in configuring auto-login, but they serve different purposes:
AutoLogonCount: This key specifies the number of times the computer should automatically log in before disabling auto-login. For example, setting AutoLogonCount
to 5
allows five automatic logins, after which the feature will be disabled. This is useful when you need only temporary automatic login.
ForceAutoLogon: When set to 1
, this key forces the auto-login feature to stay enabled even after a user logs out. Unlike AutoLogonCount
, ForceAutoLogon
does not limit the number of automatic logins, making it ideal for kiosks or systems that require continuous automatic login.
0 Comments