[英]How to set to user account value “must not enter a user and password to use this computer” through c# code
如何设置用户帐户值“必须不输入用户名和密码才能使用此计算机”,在启动计算机时,用户不必通过c#代码插入用户名和密码
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. 一种方法是清除用户密码,在这种情况下,如果它是Windows XP或更高版本中系统上的唯一用户帐户,它将自动登录。
The other way to do it, is to create three registry entries under HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon : 另一种方法是在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 可在此处获得更多信息: 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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.