Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rename administrator 1

Status
Not open for further replies.

bn2hunt

MIS
May 15, 2003
203
US
I would like to be able to rename the administrator account. However every time I try to rename a built in account I get a permission error. My user has local administrator rights and I am logged in as myself. Is it possible to rename built in accounts?

Thanks

Dan
 
Try this, it works for me

Option explicit
'On Error Resume Next

Dim objWshShell, objFSO

'Initiliase a few useful bits...
Set objWshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Rename Consultant account and set a few attributes
RenameUser GetLocalComputerName(),"Administrator","SFAdmin","Sfriday renamed Admin"


Msgbox "Admin Account renamed"

'****************************************************************************************
'Functions and Subs below here...
'****************************************************************************************
Sub RenameUser(strDomain,strOldUsername,strNewUsername,strDescription)

Dim objComputer, objUser, objMoveUser

Set objComputer = GetObject("WinNT://" & strDomain)
Set objUser = GetObject("WinNT://" & strDomain & "/" & strOldUsername & ",user")
objUser.FullName = strDescription
objUser.Description = strDescription
objUser.SetInfo
Set objMoveUser = objComputer.MoveHere(objUser.ADsPath, strNewUsername)

Set objComputer = nothing
Set objUser = nothing
Set objMoveUser = nothing

End Sub
'****************************************************************************************
function GetLocalComputerName()

Dim objNet

Set objNet = WScript.CreateObject("WScript.Network")
GetLocalComputerName = objNet.ComputerName

Set objNet = Nothing

end function
'****************************************************************************************

Regards
Steve Friday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top