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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add system name to add account script? 1

Status
Not open for further replies.

DjCalvin

IS-IT--Management
Apr 4, 2006
2
0
0
US
I am trying to rename my administrator account on a few machines in a test environment, but I am looking to add the system name to end of the name..
in this, it renames Administrator to jose.
But what I would like is:
joseSYSTEM1 (system1 is the name of the machine)
Is this possible? I can display the computer name, but I am not sure how to add that into this to make it do what I want.


Code:
strComputer = "."
strNewName = "jose"


set objComputer = GetObject("WinNT://" & strComputer)
set objUser = GetObject("WinNT://" & strComputer & _
                        "/Administrator,user")
set objNewUser = objComputer.MoveHere

(objUser.ADsPath,strNewName)
WScript.Echo "Woot! Renamed the account to: " & strNewName

thanks in advance.
- Cal

 
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
strNewName = "jose" & strComputer
...code

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
you are too fast dm! =)

Set objComputer = CreateObject("Shell.LocalMachine")
strComputer = objComputer.MachineName '<--- NETBIOS name
strAdmin = "Administrator"
strNewName = "jose" & UCase(strComputer) '<--- Append to name (jose)
Set objComp = GetObject("WinNT://" & strComputer)
Set objUser = GetObject("WinNT://" & strComputer & "/" & strAdmin)
objComp.MoveHere objUser.ADsPath, strNewName
MsgBox "Administrator renamed to: " & strNewName

now if you'll excuse me i need to rename my admin acct from joseHPXPSP2 back to administrators...
 
Awesome! thank you very much!


-------------------------------------
DjCalvin

MCSE
CCNA

- trying to learn vbscript, bear with me folks if I ask stupid questions. :)
--------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top