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

Rename server with vbscript

186 views
Skip to first unread message

Andre vWG

unread,
Oct 28, 2002, 3:57:15 AM10/28/02
to
Dear reader,

I have a 'how to...' question:

How to rename a NT4-server with vbscript?

Our servers are called: HE_xyz_SRV_001

There new name will be: HE_xyz_SRV_002

Thanks for reading and maybe thanks for writing back,

André vWG

Torgeir Bakken (MVP)

unread,
Oct 28, 2002, 12:04:02 PM10/28/02
to
Andre vWG wrote:

Hi

You can use a command line program for this (see further below), or the computer
name change can be done with some registry changes...


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

' this could be supplied to the script as an command line argument as well
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"


=========================================================
Changing computer name with a command line utility:

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

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.

Any comments, bug reports or suggestions for improvements are very welcome.
</quote>

--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway


Andre vWG

unread,
Oct 29, 2002, 5:58:31 AM10/29/02
to
Thanks (again) Torgeir,

The script did it!

André

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in
news:3DBD6E02...@hydro.com:

0 new messages