Hello!
The logon information is here.
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/WindowsNT/CurrentVersion/WinLogon
If you want the machine to log on, here should be the following string values:
AutoAdminLogon = 1
DefaultDomainName = Your domain name or the computer name
DefaultUserName = the username the computer will login with
DefaultPassword = the usernames password
Here follows a VBScript that can change these registry values. You have to change the domainname, username and password in the script, in the function SetAutoLogon.
If you change the SetAutoLogon function, so it accepts input parameters, you could use this script in the scheduling tasks in Windows XP.
=============================================================
Option Explicit
'******************************************************************
'* Constants
'******************************************************************
const KEY_QUERY_VALUE = &H0001
const KEY_SET_VALUE = &H0002
const KEY_CREATE_SUB_KEY = &H0004
const DELETE = &H00010000
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
'******************************************************************
'* Global Variables
'******************************************************************
Dim strReturnValue
Dim ReturnValue
Dim strDomain
Dim strUser
Dim strPassword
Dim objNetwork
Dim strComputer
Dim objComputer
'******************************************************************
' Wscript.Echo "The Begining"
'******************************************************************
'******************************************************************
'* Create A registry key
'******************************************************************
'Example of using the CreateARegistryKey and SetARegistryKey
strReturnValue = CreateARegistryKey("SOFTWARE\BBB\BB")
strReturnValue = SetARegistryKey("SOFTWARE\BBB\BB","Ready" ,"1")
If (strReturnValue <> "-1") Then
' Wscript.Echo "Ready Flag = " & strReturnValue
'******************************************************************
'* Script Code
'******************************************************************
' Wscript.Echo "The Script Begins" & vbTab & Now & vbNewLine
'******************************************************************
'Get the computer name. We need this for the reboot function.
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
'Here we change the registry, to the right user that will be automatically
'logged in.
strReturnValue = SetAutoLogon
If (strReturnValue <> "-1") Then
' Wscript.Echo "Setting Atuologon successed"
Else
Wscript.Echo "Error Setting Autologon in the registry = " & strReturnValue
End If
'**********************************************************************
'* RebootComputer
'**********************************************************************
ReturnValue = RebootComputer(strComputer)
if ReturnValue <> 0 Then
Wscript.Quit -6
End If
'******************************************************************
' Wscript.Echo "The End"
'******************************************************************
'**********************************************************************
'* NAME: CreateARegistryKey
'* FUNCTION:
'**********************************************************************
Function CreateARegistryKey(strKeyPath)
Dim oReg
Dim sReturn
On Error Resume Next
Set oReg = GetObject("winmgmts://./root/default:StdRegProv")
sReturn = oReg.CreateKey(HKEY_LOCAL_MACHINE,strKeyPath)
Set oReg = Nothing
If Err <> 0 then
'* Wscript.Echo Err.Source & " " & Hex(Err) & ": " & Err.Description & "Error # " & CStr(Err.Number)
Err.Clear
CreateARegistryKey = "-1" 'Error
Else
CreateARegistryKey = "0" 'OK
End If
End Function
'**********************************************************************
'* NAME: SetARegistryKey
'* FUNCTION:
'**********************************************************************
Function SetARegistryKey(strKeyPath ,strKey ,strKeyValue)
Dim oReg
Dim sReturn
On Error Resume Next
Set oReg = GetObject("winmgmts://./root/default:StdRegProv")
sReturn = oReg.SetStringValue (HKEY_LOCAL_MACHINE,strKeyPath,strKey,strKeyValue)
Set oReg = Nothing
If Err <> 0 then
'* Wscript.Echo Err.Source & " " & Hex(Err) & ": " & Err.Description & "Error # " & CStr(Err.Number)
Err.Clear
SetARegistryKey = "-1" 'Error
Else
SetARegistryKey = "0"
End If
End Function
'**********************************************************************
'* NAME: GetARegistryKey
'* FUNCTION:
'**********************************************************************
Function GetARegistryKey(strKeyPath, strKey)
Dim oReg
Dim strKeyValue
Dim sReturn
On Error Resume Next
Set oReg = GetObject("winmgmts://./root/default:StdRegProv")
sReturn = oReg.GetStringValue (HKEY_LOCAL_MACHINE,strKeyPath,strKey,strKeyValue)
Set oReg = Nothing
If Err <> 0 then
'* Wscript.Echo Err.Source & " " & Hex(Err) & ": " & Err.Description & "Error # " & CStr(Err.Number)
Err.Clear
GetARegistryKey = "-1" 'Error
Else
GetARegistryKey = strKeyValue
End If
End Function
'**********************************************************************
'* NAME: RebootComputer
'* FUNCTION: Reboot Computer Need the Computer Name as input
'**********************************************************************
Function RebootComputer(sComputer)
Dim objWMIService
Dim colOperatingSystems
Dim objOperatingSystem
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Shutdown)}!\\" & sComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()
Next
Set colOperatingSystems = Nothing
Set objWMIService = Nothing
If Err = 0 then
RebootComputer = "0" 'OK
Else
Wscript.Echo Err.Source & " " & Hex(Err) & ": " & Err.Description & "Error # " & CStr(Err.Number)
Err.Clear
RebootComputer = "1" 'Error
End If
End Function
'**********************************************************************
'* NAME: SetAutoLogon
'* FUNCTION:
'**********************************************************************
Function SetAutoLogon()
strReturnValue = SetARegistryKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","AutoAdminLogon" ,"1")
If (strReturnValue <> "-1") Then
' Wscript.Echo "Ready Flag = " & strReturnValue
Else
Wscript.Echo "Error reading Ready Flag = " & strReturnValue
End If
strReturnValue = SetARegistryKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultDomainName" ,"DomainName")
If (strReturnValue <> "-1") Then
' Wscript.Echo "Ready Flag = " & strReturnValue
Else
Wscript.Echo "Error reading Ready Flag = " & strReturnValue
End If
strReturnValue = SetARegistryKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultUserName" ,"UserName")
If (strReturnValue <> "-1") Then
' Wscript.Echo "Ready Flag = " & strReturnValue
Else
Wscript.Echo "Error reading Ready Flag = " & strReturnValue
End If
strReturnValue = SetARegistryKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultPassword" ,"Password")
If (strReturnValue <> "-1") Then
' Wscript.Echo "Ready Flag = " & strReturnValue
Else
Wscript.Echo "Error reading Ready Flag = " & strReturnValue
End If
SetAutoLogon = strReturnValue
End Function
'******************************************************************
'*
'******************************************************************
==========================================================
Happy Coding and Good Luck!
/Jörgen Jönsson