Programmatic implementation of Windows system automatic login

Source: Internet
Author: User

Programmatic implementation of Windows system automatic login

principle :

Implemented through registry modification. Windows built-in mechanism of automatic login, when logging on to the system, Winlogon will check the registry is not set to automatically login, if set up will read the user name and password, and then to verify, after the login into the system.

Method :

Registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

Key values:

Key value Setting the value Role
AutoAdminLogon 1; 1 means automatic login, 0 disables automatic logon
DefaultDomainName Setting the value Domain name, if not, leave it blank
DefaultUserName Abc User name used to log on to the system
DefaultPassword 123 Log in to the system using the user name of the password, if you want to encrypt the save to delete this key value
DontDisplayLastUserName 1

Note that the following two key values must be removed or a notification dialog box will be displayed.

    • LegalNoticeCaption
    • LegalNoticeText

There are also 2 key values, with the following functions:

    • Ignoreshiftoverride ignores the SHIFT key, by default the login dialog box (even set to auto-login) is displayed by pressing SHIFT when you turn it on, and when you set it to 1, pressing the SHIFT key is useless.
    • AutoLogonCount setting the number of automatic logins
    • ForceAutoLogon the value to be dropped

Special attention :

Because the password is saved in plaintext and is not secure, Windows provides a secret place to save the encrypted password, which is in the LSA. The AutoLogon tool in Sysinternals is to keep the password in. In Winlogon, it will first go to the LSA to find the "DefaultPassword" information, found after the use of this password, if not found on the registry to find "DefaultPassword" value.

Read and write the LSA code, which is found in pinvoke.net. Original:
Http://www.pinvoke.net/default.aspx/advapi32/DefaultPassword.html

where C + + code is provided by Microsoft: http://msdn.microsoft.com/en-us/library/aa378826 (vs.85). aspx
C # code is: http://www.pinvoke.net/default.aspx/advapi32/LsaRetrievePrivateData.html
After obtaining the Luautil class, you can use it as a downward

Lsautil LSA = new Lsautil ("DefaultPassword"); LSA. Setsecret ("abc"); Console.Write (LSA. Getsecret ());

Http://www.cnblogs.com/greenerycn/archive/2009/11/18/windows_auto_logon.html

Programmatic implementation of Windows system automatic login

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.