How to set to use开发者_开发技巧r account value "must not enter a user and password to use this computer" when power up the computer the user wouldn't have to insert his user name & password through c# code
There are two ways of doing this, and both ways are fairly insecure.
One way to do it would be to clear out the password for the user, in which case, if it is the only user account on the system in Windows XP or higher, it will automatically log itself in.
The other way to do it, is to create three registry entries under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon:
DefaultUserName (reg_sz): Set to the user's username DefaultPassword (reg_sz): Set to the user's password AutoAdminLogon (dword): Set to 1 to enable; 0 to disable
More information is available here: http://support.microsoft.com/kb/315231
Please be aware that this information is visible in the registry to anyone who has the ability to run the registry editor, so make sure the password is not something used elsewhere, or that the workstation is secure from other users.
To set this value through code, you can do the following:
RegistryKey winlogonKey = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows NT").OpenSubKey("CurrentVersion").OpenSubKey("WinLogon", true);
winlogonKey.SetValue("DefaultUserName", "the_user's_username");
winlogonKey.SetValue("DefaultPassword", "the_user's_password");
winlogonKey.SetValue("AutoAdminLogon", 1);
精彩评论