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

Command line to change computer name

131 views
Skip to first unread message

DC

unread,
Oct 21, 2005, 11:42:44 AM10/21/05
to
Hi all. I am trying to write a script to change the name of a
computer. Is there a command I can use to do this? If not, what registry
entries do I need to modify?

Thanks,
Dave

Torgeir Bakken (MVP)

unread,
Oct 21, 2005, 12:00:24 PM10/21/05
to
DC wrote:

Hi,

A couple of options:

Option 1:

Use the netdom.exe that is in the "Windows XP Service Pack 2 Support
Tools" package, and take a look at the RENAMECOMPUTER parameter.

Windows XP Service Pack 2 Support Tools download:
http://www.microsoft.com/downloads/details.aspx?FamilyID=49ae8576-9bb9-4126-9761-ba8011fabf38


C:\Program Files\Support Tools>netdom.exe HELP RENAMECOMPUTER
The syntax of this command is:
NETDOM RENAMECOMPUTER machine /NewName:new-name
/UserD:user [/PasswordD:[password | *]]
[/UserO:user [/PasswordO:[password | *]]]
[/Force]
[/REBoot[:Time in seconds]]

NETDOM RENAMECOMPUTER renames a computer that is joined to a domain.
The computer object in the domain is also renamed. Certain services,
such as the Certificate Authority, rely on a fixed machine name. If
any services of this type are running on the target computer, then a
computer name change would have an adverse impact.

machine is the name of the workstation, member server, or domain
controller to be renamed

(rest of help listing snipped)


Option 2:

Changing computer name with a free 3rd party command line utility:

www.willowhayes.co.uk/download/compname.exe

(Note: If used on a domain computer, domain membership gets broken)

Subject: Setting computer name at command prompt from SMBIOS (asset tag)
info
Date: Thu, 17 Oct 2002 23:16:32 +0100
From: "Oli Restorick" <use...@willowhayes.co.uk>

<quote>
I'm reposting this, because looking at the log files for my web site,
it is clear that quite a few people tried to download the file but, due
to problems with my web host, the download didn't happen.

That should now be fixed. Meanwhile, I've made quite a few updates to
the program.

Compname.exe is a utility to generate a computer name to your
specifications, optionally pulling in data including asset tag/serial
number from the chassis, motherboard and system, System UUID/GUID, mac
address, IP address octets, date, and a random element.

The program should run fine on all Windows platforms since Windows 95,
including Windows NT. If available (i.e 2000, XP, .net) the program
will call SetComputerNameExA from kernel32.dll. If this function is
not available, it calls SetComputerNameA from the same DLL. This
ensures that, for 2000 and above, the DNS host name and the NetBIOS
name both get set properly.

Download the utility and type "compname.exe /?" to get the syntax.
It's pretty easy.

For example,

"compname.exe /c jupiter" sets the computer name to jupiter
"compname.exe /c PC-?k-?l" will use the IP address. If the IP address
is 192.168.1.100, the name will be "PC-1-100"
"compname.exe /c pc-?s" sets the machine to "pc-abcdef" where abcdef is
the SMBIOS asset tag/serial number.
"compname.exe /c pc-?9" generates a name including nine random
characters.

The program can also be used for reading any of these fields (by using
the /d[isplay] option), or for piping these numbers into other
applications.

"compname.exe /s" will give you a summary of the SMBIOS, IP and MAC
information.

</quote>

--
torgeir, Microsoft MVP Scripting, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Tom Porterfield

unread,
Oct 21, 2005, 12:06:23 PM10/21/05
to

See if the following article helps:

How To Use the Netdom.exe Utility to Rename a Computer in Windows XP
http://support.microsoft.com/kb/298593
--
Tom Porterfield
MS-MVP Windows
http://support.telop.org

Please post all follow-ups to the newsgroup only.

DC

unread,
Oct 21, 2005, 1:44:11 PM10/21/05
to
Tom Porterfield <tppo...@mvps.org> wrote in
news:urDWjll1...@TK2MSFTNGP12.phx.gbl:

> DC wrote:
>> Hi all. I am trying to write a script to change the name of
>> a
>> computer. Is there a command I can use to do this? If not, what
>> registry entries do I need to modify?
>
> See if the following article helps:
>
> How To Use the Netdom.exe Utility to Rename a Computer in Windows XP
> http://support.microsoft.com/kb/298593

Thank you both for the info. Will netdom work if you computer is
part of a workgroup and not part of a domain? Do both utilities force a
reboot of the computer or can you reboot when you want (i.e. after
performing other config changes)?

Thanks again,
Dave

Tom Porterfield

unread,
Oct 21, 2005, 3:30:36 PM10/21/05
to
DC wrote:
> Thank you both for the info. Will netdom work if you computer is
> part of a workgroup and not part of a domain? Do both utilities force a
> reboot of the computer or can you reboot when you want (i.e. after
> performing other config changes)?

As far as I know, netdom only works for domain computers. For
non-domain PC's see Torgeir's option 2. I don't know if that utility
forces a reboot or allows you to reboot when you choose.

nbuck459

unread,
Nov 8, 2005, 4:38:34 PM11/8/05
to
Does anyone know how to script Option 1 to prompt for the current and
new computer names?

Kelly

unread,
Nov 8, 2005, 11:32:47 PM11/8/05
to
Haven't tried but could be done, but per the subject: 131 (right hand
side):
http://www.kellys-korner-xp.com/xp_tweaks.htm

--

All the Best,
Kelly (MS-MVP/DTS&XP)

Troubleshooting Windows XP
http://www.kellys-korner-xp.com

"nbuck459" <nb...@rocketmail.com> wrote in message
news:1131485914.4...@o13g2000cwo.googlegroups.com...

0 new messages