开启/关闭 Windows 自动登录(AutoAdminLogon 注册表)

通过 Winlogon 注册表键值让开机后直接进入桌面,无需输入密码。

Windows注册表密码安全高风险
用 reg add 在 HKLM\...\Winlogon 下设置 AutoAdminLogon、DefaultUserName 和 DefaultPassword 即可开启自动登录;把 AutoAdminLogon 设为 0 即关闭。

01命令

命令
$ reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d yourname /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d yourpassword /f

02作用说明

AutoAdminLogon 为 1 时,Windows 会跳过登录界面,直接用 DefaultUserName 指定的账户和 DefaultPassword 中的密码登录。适合无人值守的客厅电脑或一体机。想关闭时,把 AutoAdminLogon 改回 0 并删除 DefaultPassword 即可。

03风险

风险高风险
使用条件Run Command Prompt as administrator. Only sensible on a single-user machine in a physically safe place.
!注意: 密码在注册表里是可读的明文,能接触到这台电脑的人都能看到——公共场合或随身设备千万不要开启。

04撤销

撤销
$ reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 0 /f
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /f

05来源

  • Autologon for Windows
    Microsoft Learn · vendor-doc · 2026-09-17
    依据: Describes the AutoAdminLogon, DefaultUserName and DefaultPassword Winlogon registry values used to log a user in automatically.

最后验证: 2026-09-18 · 分类: 安全与隐私

06相关方案