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

Rename Computer

Status
Not open for further replies.

sktala

MIS
Jan 2, 2007
12
US
Hi everyone, I hope you have a wonderful day. I have this delima and seek you help. My company went through a division wide reorg, and our name got change. We name out computers with the division name prefix (ex. ITS-computer1). I need to change the computer name, so I'm looking for a script to change the name at client side and also at DC side in AD. Please help!

Thanks very much.
 
Option Explicit
Set ws = CreateObject("WScript.Shell")
Dim ws, title, reg_key, comp_name, new_name
Dim itemtype
reg_key = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\"
comp_name = ws.RegRead(reg_key & "ComputerName")
title = "Change Computer Name"
new_name = InputBox("Type new Name and click OK", title, comp_name)
If new_name <> "" Then
ws.RegWrite reg_key & "ComputerName", new_name
end If
 
Thanks jfdabiri for quikly reply. Does this script update computer account in AD also? is there a way to update all computers an OU instead of doing one by one using input box?

Thank you again.
 
this has to be run on every computer because it modifies the registry. there are ways to get around it so that each computer name is made up of some unique string instead of a prompt. you can subsitute a unique string instead of the inputbox.
 
How can this same process be done in Visual Basic 6?
Any of the givin commands different?
 
Your best solution is to use the resource kit utility NETDOM. You can easily script it and it will ensure that the computername is change both locally and in AD.

Changing the name in the registry will not update AD and your computers will loose connectivity to the domain.



I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top