This script will load a command line variable for the username or can auto to administrator and password from an ini file.
' Initialization
Set wshNetwork = CreateObject("WScript.Network")
Set shell = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
' Get parameters
Program = "AutoLog.vbs"
If WScript.Arguments.Count > 0 then
username = WScript.Arguments.Item(0)
Else
username = TranslateLocalUser("Administrator")
End if
If WScript.Arguments.Count > 1 then
password = WScript.Arguments.Item(1)
Else
password = ReadIni("C:\Build\Settings.ini", "LocalAdmin", "localAdminPassword")
End if
computerName = wshNetwork.ComputerName
' Set the AutoAdminLogon registry keys
shell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon", "1", "REG_SZ"
shell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", username, "REG_SZ"
shell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName", computerName, "REG_SZ"
shell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword", password, "REG_SZ"
shell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoLogonCount", &H00000005, "REG_DWORD"
' READINI ( file, section, item )
' file = path and name of ini file
' section = [section] must not be in brackets
' item = the variable to read
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
This script will load a command line variable for the username or can auto to administrator and password from an ini file.
Usage:
cscript.exe //nologo c:\build\Autolog.vbs
Remove AutoLogon
Usage:
cscript.exe //nologo c:\build\DelAuto.vbs
Share this post
Link to post
Share on other sites