How Do I Rename Multiple Computers Using Their IP Address?

I have about 200 clients that occasionally get re-imaged. They do not belong to domains. They all have static IP addresses. Using the static IP addresses how could I write a script that would rename each computer? It doesn't matter what it names them... It would be nice if it named each one the same name every time I ran the script though I suppose. Is [HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\ComputerName\] the only registry key I need to change in order to change a computer's name? If so, how could I write a batch script that would do something like this:


For that example I would need a reg file for every computer though. I'm sure there is some way to do it with a variable instead.... Help?
Who is Participating?
LongbowConnect With a Mentor Commented:
Yes, you can use it directly sinds you do not have to access a domain.
Psshutdown can terminate the job.

Ghostwalker is the Ghost's tool wich can change the SID and can give a computername to the computer before the first logon.
I do not remember the exact name of the file. But it is near. Ghstwlkr.exe maybe.
It is a DOS application.

If the computer needs the presence of a local administrator while ghosting, running the script locally is a good solution.

Or if you already know the IP addresses used for the network you can automate the process. See my above post.
If MAC = "XXX" Then baptize NewComputername.
One line by computer.

Here is the link to a Visual Basic Script wich gives you any info about a Network Card.
From this point your ghost image can automate the process.
Lee W, MVPTechnology and Business Process AdvisorCommented:
The computer name is not simply a registry entry.  You'll likely need to use the netdom command.  For some information on this, see:

You might also want to try looking over this:

Here is the tool you need to change any computername.
You can download it from this link.

You can change a computername remotely with Psexec tool from the PsTools Suite found at

To automate the process from the image you need to script it.
I will suggest to have the mac address and the new computername
 in order to change it correctly.

Wich imaging system do you use ?
How do you define wich static address have each computer ?
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Grime121Author Commented:
We use Symantec Ghost 8.0. All of the static IP addresses are assigned by the DHCP server according to MAC address. I already use pstools a lot, and I've been trying to figure out a way to use it for this problem since I know you can run it according to IP address. I think this will work. Here is what I'm going to use in a script for each computer:

psexec.exe \\192.168.0.x babtize <new name>
Grime121Author Commented:
Oh, one more thing. Will Netware cause any problems with this? We use Novell on these computers.
Your commandline must  have the path & filename in quotes.
The options can follow the last quote.

It is not an so easy thing.
Now i know you connect to differents domains :
When changing the username you need to put each computer in a workgroup, then change the computername, then put it back in the domain. It will take two or three reboots. The keyboard and mouse must be locked to prevent the users to use the computer during this session.
My script is a batch file with 116 lines of code.
It needs five executables to do all the job.

The solution i gave you is a solution to change computernames to the fly, not after ghosting a PC.
Or maybe you have a script wich does the job in one execution.
But you need to have a report because you do not know wich computer were turned on at this time.

The solution i used to ghost my training rooms is a list (.txt file) with all computernames and macaddresses in two columns.

We had a DOS tool wich read the macaddress and the computername from a floppy disk ant put the value in a environment variable.

The variable can be sent to Ghostwalker in order to change accordingly the computername.
Grime121Author Commented:
Well, all of the computers are already in workgroups. We don't use a domain for those computers. I use psexec quite frequently, so I'm pretty familiar with it. Since they are not in domains, can't I just simply run that 'babtize' script to rename them? I found an option in Ghost one time to rename computers randomly after they are imaged, but I looked for about 15 minutes yesterday and could not find it. Plus, it would be nice to assign the computers the same name every time they are imaged rather than a random name every time. I'm not too worried about which computers are turned on at the time. The computers are in labs at a university. After we image them we can just run the script for that lab that will include the renaming commands. Does this sound like a good solution?
Grime121Author Commented:
Wow, I found something even better:

That will rename them by doing a reverse dns lookup and using whatever the PTR record is for that IP address. Very slick. Of course, the reverse lookup zone has to be set to not allow dynamic updates.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.