Set windows auto login script

  
        /* @Setup boot from @strUser, username @strPass, password @strAutoAdminLogon, when the value is 1, automatically log in, 0 cancel @return, return TRUE successfully, otherwise return FALSE */BOOL SetWindowAutoLogin(LPCTSTR strUser, LPCTSTR strPass , LPCTSTR strAutoAdminLogon) { HKEY hKey; LONG ntStatus = RegOpenKey(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Winlogon"),&hKey); if (ERROR_SUCCESS != ntStatus) return FALSE ; ntStatus = RegSetValueEx(hKey,_T("DefaultUserName"),0,REG_SZ,(CONST BYTE*)strUser,_tcslen(strUser)*sizeof(TCHAR)); if (ERROR_SUCCESS != ntStatus) return FALSE; ntStatus = RegSetValueEx (hKey, _T("DefaultPassword"), 0, REG_SZ, (CONST BYTE*) strPass, _tcslen(strPass)*sizeof(TCHAR)); if (ERROR_SUCCESS != ntStatus) return FALSE; ntStatus = RegSetValueEx(hKey,_T ("AutoAdminLogon"),0,REG_SZ,(CONST BYTE*)strAutoAdminLogon,_tcslen(strAutoAdminLogon)*sizeof(TCHAR)); if (ERROR_SUCCESS != ntStatus) return FALSE; RegCloseKey(hKey); return TRUE; }zh-CN"],null,[0.92426991],zh-CN"]]]
Copyright © Windows knowledge All Rights Reserved