Vbscript / Operating System / Autologon And Runonce
The following code set the appropriate registry keys to login automatically and run a program once on the next login. This code runs on Server 2003, Windows XP and Vista.
Set objShell = WScript.CreateObject("WScript.Shell")
strUsername = "Admin" strPassword = "Password123"
strRunOnce = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce\joinDomain" objShell.RegWrite strRunOnce, "cmd.exe /c cscript c:\install\myscript.vbs", "REG_SZ"
strAutoLogon = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\winlogon" objShell.RegWrite strAutoLogon & "\AutoAdminLogon", "1", "REG_DWORD" objShell.RegWrite strAutoLogon & "\DefaultUserName", strUsername, "REG_SZ" objShell.RegWrite strAutoLogon & "\DefaultPassword", strPassword, "REG_SZ"
Please note that a disclaimer applies to any code on this page.
|