Programming for Windows System Automatic Login

Source: Internet
Author: User
Document directory
  • Programming for Windows System Automatic Login

Programming for Windows System Automatic Login

Principle:

You can modify the registry. Windows has a built-in automatic logon mechanism. When you log on to the system, Winlogon checks whether automatic logon is set in the registry. If you set it, the user name and password will be read and verified, log on to the system.

Method:

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

Key value:

Key Value Set Value Function
AutoAdminLogon 1; 1 indicates automatic logon, 0 indicates automatic logon is disabled
Defaultdomainname Set Value Domain name. leave it blank if it does not exist.
DefaultUserName ABC Username used to log on to the system
Defaultpassword 123 The password used by the user name used to log on to the system. Delete this key value if you want to encrypt and save it.
DontDisplayLastUsername 1  

Note: The following two key values must be deleted; otherwise, a notification dialog box is displayed.

  • Legalnoticecaption
  • Legalnoticetext

There are also two key values for the following functions:

  • Ignoreshiftoverride ignores the Shift key. By default, the logon dialog box is displayed by pressing shift at startup (even if it is set to automatic logon). If it is set to 1, it is useless to press shift.
  • Autologoncount
  • Forceautologon: The value must be deleted.

Special note:

Because the password is stored in plain text, it is not safe, so a secret is provided in Windows to save the encrypted password, that is, in LSA. In sysinternals, The autologon tool saves the password. In Winlogon, it will first use "defaultpassword" in LSA, and then use this password. If it cannot be found, it will go to the Registry to find the "defaultpassword" value.

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

Among them, C ++ code is provided by Microsoft: http://msdn.microsoft.com/en-us/library/aa378826 (vs.85). aspx

C # code: http://www.pinvoke.net/default.aspx/advapi32/LsaRetrievePrivateData.html

After obtaining the luautil class, you can call it as follows,

LSAutil lsa = new LSAutil("DefaultPassword");lsa.SetSecret(“abc”);Console.Write(lsa.GetSecret());
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.