Using VBS to set the last user logged on (Windows XP)

The following VBS script will change the last user logged on, information which is stored in the registry simply copy it into a text document and save it with the vbs file extension.

 

This script has been used with Windows XP on an Active Directory domain to change which user was last logged on.

 

xp-login

 

on error resume next


    dim WSHShell
    Set WSHShell = Wscript.CreateObject("WScript.Shell")
    dim strRegKey
    strRegKey = "HKLMSOFTWAREMicrosoftWindows NTCurrentVersionWINLOGON"

StrUser = InputBox("Please enter in username," & vbCrLf & vbCrLf & "e.g. joe.local", "Set Last logged on", "username")
StrDomain = InputBox("Please enter in domain for logon," & vbCrLf & vbCrLf & "e.g. DOMAIN", "Set Logon Domain", "DOMAIN")

    wshShell.RegWrite strRegKey & "DefaultDomainName", StrDomain, "REG_SZ"
    wshShell.RegWrite strRegKey & "DefaultUserName", StrUser, "REG_SZ"
    wshShell.RegWrite strRegKey & "AltDefaultDomainName", StrDomain, "REG_SZ"
    wshShell.RegWrite strRegKey & "AltDefaultUserName", StrUser, "REG_SZ"
    wshShell.RegWrite strRegKey & "AutoAdminLogon", "0", "REG_SZ"


WScript.Echo "Setup Completed. Please restart the computer to complete the process"