Renaming computer and Account in Windows 2000

G

Guest

Hi,

I have been trawling the net and ms site for a script which renames both the
computer account and the physical computer, the scenario is basically I have
about 200 users to join to our new domain which I am doing via a netdom
command running from login script, trouble is we want to rename the computers
to include a three digit prefix. Whether this is done before joining the
domain or after i'm not too fussed, before would be my preference however.

I have found a script to rename the computer account but not the computer!!
if I had XP apparently it wouldn't be a problem.

If anyone knows of such a tool or script to help me achieve this task
without physically touching each pc would be appreciated..

Thanks

Kevin
 
G

Gerry Hickman

Hi,

The way I do it, is to rename the computer in the registry and then reboot
it, but LOOK OUT. As soon as you rename it and reboot it, it might drop off
the network completely unless you've got your DNS and/or WINS set up to cope
with the changes.

You have to make sure everything is done in the right order and that every
related name is changed. DNS, WINS, Computer, Secure Channel.
 
G

Guest

Hi Gerry,

Thanks for your advice, hmm I hope it is that simple, so you are talking
about this particular key:
HKLM\system\currentcontrolset\control\computername\computername

is that the only place you changed? have your workstations been behaving
since? the Schannel and DNS etc. isnt a problem as I am going to execute this
reg merge from a netware login script before they join AD... now, I just need
to prefix the computername, unfortunately %computername% will not resolve
here so any ideas how I just add the prefix to the existing name..

Thanks

Kevin
 
G

Gerry Hickman

Hi Kevin,
Thanks for your advice, hmm I hope it is that simple, so you are talking
about this particular key:
HKLM\system\currentcontrolset\control\computername\computername

Kind of.
is that the only place you changed?
No.

have your workstations been behaving
since?
Perfect.

the Schannel and DNS etc. isnt a problem as I am going to execute this
reg merge from a netware login script before they join AD...

Hmm, well I can't comment on that, a login script sounds a bit odd.
now, I just need
to prefix the computername, unfortunately %computername% will not resolve
here so any ideas how I just add the prefix to the existing name..

Here's an example of my "rename" function. I unjoin the box from the
domain with NetDom, reboot, adjust DNS and WINS, then run this script,
reboot, then re-join the box with NetDom. Something like that anyway -
it's been a while since I had to do it. I remember being able to
automate the whole thing and ran it on dozens of machines.

The function below can't be run without my custom JScript libraries, but
it's very easy to see how it works, just use the conepts in your own
scripts.

BEWARE OF LINE WRAP!


// ReanmeComputer.wsf
function rename(strOldName, strNewName) {

var strRegPath =
"System\\CurrentControlSet\\Control\\ComputerName\\ComputerName";
var strValueName = "ComputerName";
var r = new Reg();
r.connect(oLoc, strOldName);
var strCurrentName = r.readString(r.HKLM, strRegPath, strValueName)
if(!strCurrentName) {
_trace("*** Problem Reading Registry ***");
return false;
}

_trace(strOldName + " has the current NetBIOS name of " + strCurrentName);

if(!r.writeString(r.HKLM, strRegPath, strValueName, strNewName)) {
_trace("*** Problem writing Registry ***");
return false;
}

_trace(strNewName + " written to NetBIOS name in registry");

strRegPath = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters";
strValueName = "NV Hostname";

if(!r.writeString(r.HKLM, strRegPath, strValueName, strNewName)) {
_trace("*** Problem writing Registry ***");
return false;
}

_trace(strNewName + " written to to hostname in reg");

r.dispose();

return true;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top