Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

change a computer name from command line?

75 views
Skip to first unread message

brett

unread,
Sep 11, 2002, 12:55:15 AM9/11/02
to
I would like to change a computer name from a command
line. Is this possible? I am working on a script that
will prompt for old computer name and removes it from the
domain, then prompt for new computer name, and finally re-
add it to the domain (netdom).

Any help would be greatly appreciated.


Thanks

Torgeir Bakken

unread,
Sep 11, 2002, 8:14:08 AM9/11/02
to
brett wrote:

Hi

You *must* have a reboot between the computer renaming and the re-adding to the
domain.

The only command line util I have seen that changes the computer name is
Sysinternals NewSID.exe (I guess Ghost has one as well) . Downside: it will give
the computer a new SID and the Registry will grow, so this is a bit overkill...

NewSID.exe
http://www.sysinternals.com/ntw2k/source/newsid.shtml

newsid /a newname
Would have NewSID run without prompting, change the computer name to "newname"
and have it reboot the computer if everything goes okay.


The computer name change can be done with some registry changes instead...


'Changing computer name for WNT/W2k/WXP with vbscript:

sNewName = "put new name here"

Set oShell = CreateObject ("WSCript.shell")

sCCS = "HKLM\SYSTEM\CurrentControlSet\"
sTcpipParamsRegPath = sCCS & "Services\Tcpip\Parameters\"
sCompNameRegPath = sCCS & "Control\ComputerName\"

With oShell
.RegDelete sTcpipParamsRegPath & "Hostname"
.RegDelete sTcpipParamsRegPath & "NV Hostname"

.RegWrite sCompNameRegPath & "ComputerName\ComputerName", sNewName
.RegWrite sCompNameRegPath & "ActiveComputerName\ComputerName", sNewName
.RegWrite sTcpipParamsRegPath & "Hostname", sNewName
.RegWrite sTcpipParamsRegPath & "NV Hostname", sNewName
End With ' oShell

MsgBox "Computer name changed, please reboot your computer"


For a command line version that uses reg.exe, see here:

From: Clay Calvert (ccal...@Wanguru.com)
Subject: Re: Remote changing of computername
Newsgroups: microsoft.public.win2000.cmdprompt.admin
Date: 2002-04-27 20:23:45 PST
http://groups.google.com/groups?selm=5dkmcuk62bt53do2rnnuaksse806lqri1v%404ax.com


===========================================================
Command line, join domain with Netdom.exe
===========================================================

Latest version of netdom.exe can be downloaded from here:

Windows 2000 SP3 Support Tools
http://www.microsoft.com/windows2000/downloads/servicepacks/sp3/supporttools.asp

There came one updated version with SP2 as well, but I would be very surprised
if the SP3 netdom version do not work on pre SP3 computers.

Anyway, the one that came with SP2 can be found here:

Windows 2000 SP2 Support Tools
http://www.microsoft.com/windows2000/downloads/servicepacks/sp2/supporttools.asp

How To Join a Domain From the Command Line
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q150493

How to Use Netdom 2.0 to Create a Windows Computer Account on a Selected Domain
Controller
http://support.microsoft.com/support/kb/articles/Q266/6/51.ASP

Automating the Creation of Computer Accounts
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q222525


You can also test on the result of the join by testing on the return code of
netdom.exe:

From: Developer_for (add...@hotmail.com)
Subject: Joining Domain and Verifying it ....
Newsgroups: microsoft.public.scripting.vbscript
Date: 2002-04-21 23:58:57 PST
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&th=f5c28b1129d85de

--
torgeir


Marty List

unread,
Sep 11, 2002, 11:09:46 AM9/11/02
to

I wrote a KiXtart script back in 1999 that did this for NT4.0 machines. It
should work in NT5.x with a little tweaking and a newer version of
netdom.exe. If you think it will be useful to you, let me know and I'll
remove my domain account names etc. and send it to you.


"brett" <br...@yahoo.com> wrote in message
news:f4bb01c2594f$6b636640$35ef2ecf@TKMSFTNGXA11...

Reinhardt Kern

unread,
Sep 11, 2002, 7:09:14 PM9/11/02
to
"Marty List" <Bill....@sun.com> wrote:

>
>I wrote a KiXtart script back in 1999 that did this for NT4.0 machines. It
>should work in NT5.x with a little tweaking and a newer version of
>netdom.exe. If you think it will be useful to you, let me know and I'll
>remove my domain account names etc. and send it to you.
>

Hi Marty,

it would be great, if you publish this script here. (Even if it
is a bit OT.) I love using KiX, too. - But there is no kix-group
in the usenet.

Reinhardt
--
mens sana in corpore satiato
(Ein gesunder Geist steckt in einem satten Körper)

0 new messages