繁体   English   中英

如何通过C#代码将用户帐户值设置为“不得输入用户名和密码才能使用此计算机”

[英]How to set to user account value “must not enter a user and password to use this computer” through c# code

如何设置用户帐户值“必须不输入用户名和密码才能使用此计算机”,在启动计算机时,用户不必通过c#代码插入用户名和密码

有两种方法可以做到,而且两种方法都不安全。

一种方法是清除用户密码,在这种情况下,如果它是Windows XP或更高版本中系统上的唯一用户帐户,它将自动登录。

另一种方法是在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

可在此处获得更多信息: http : //support.microsoft.com/kb/315231

请注意,任何有能力运行注册表编辑器的人都可以在注册表中看到此信息,因此请确保密码未在其他地方使用,或确保工作站不受其他用户的影响。

要通过代码设置此值,可以执行以下操作:

        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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM