Monday, May 25, 2015

VBSCRIPT TO RENAME LOCAL BUILTIN "ADMINISTRATOR" AND "GUEST" ACCOUNT

'This specifies the local computer
strComputer = "."

'This tells it what name to look for
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAccounts = objWMIService.ExecQuery _
("Select * From Win32_UserAccount where localaccount = True and Description = 'Built-in account for administering the computer/domain'")
'This tells it what to rename the account to
For Each objAccount in colAccounts
    objAccount.Rename "ADMIN"
Next

'This tells it what name to look for
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAccounts = objWMIService.ExecQuery _
("Select * From Win32_UserAccount where localaccount = True and Description = 'Built-in account for guest access to the computer/domain'")
'This tells it what to rename the account to
For Each objAccount in colAccounts
    objAccount.Rename "Guest"
Next