I need to change 900+ PC's to a new naming convention (great idea by none
tech bods). Does anybody have anything at all we could use to help automate
the process? Maybe a VB script using WSH?...a utility we can use to put
login scripts? I'm sure i've seen a utility you can use to change name
which is then applied on restart.
Any help gratefully accepted, Thanks guys.
Chris
> I need to change 900+ PC's to a new naming convention (great idea by none
> tech bods). Does anybody have anything at all we could use to help automate
> the process? Maybe a VB script using WSH?...a utility we can use to put
> login scripts? I'm sure i've seen a utility you can use to change name
> which is then applied on restart.
Here is a VBScript that does the job:
'Changing computer name for WNT/W2k/WXP:
sNewName = "put new name here"
Set oShell = CreateObject ("WSCript.shell")
sCCS = "HKLM\SYSTEM\CurrentControlSet\"
' look out for line wrapping!
With oShell
.RegDelete sCCS & "Services\Tcpip\Parameters\Hostname"
.RegDelete sCCS & "Services\Tcpip\Parameters\NV Hostname"
.RegWrite sCCS & "Control\ComputerName\ComputerName\ComputerName", sNewName
.RegWrite sCCS & "Control\ComputerName\ActiveComputerName\ComputerName",
sNewName
.RegWrite sCCS & "Services\Tcpip\Parameters\Hostname", sNewName
.RegWrite sCCS & "Services\Tcpip\Parameters\NV Hostname", sNewName
End With ' oShell
If you want to use WMI (to do it e.g remotely), you can use the WMI registry
provider for the RegDelete/RegWrite instead.
Note:
If I am not mistaken, you will break a domain membership renaming the computer.
--
torgeir
Yes, this will break domain membership.
Thank you for this script, Torgeir. If you'll please pardon the
plagiarism, here's a rewrite using CMD, and Reg.exe, which can be
downloaded here:
ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt40/i386/reg_x86.exe
I won't be able to test this until Monday, so I'll post a followup.
This routine assumes that c:\Rename.txt contains two columns. Column
A is the current PC name, and Column B is the new name. Simply
separate each column with a space.
This routine should also add the new PC to the domain, and remove the
old one from the domain. Maybe you'll want to add that step later...
just in case. If so, that is a one liner.
Set CCS=HKLM\SYSTEM\CurrentControlSet\
Set CN=ComputerName
For /f "tokens=1,2" %%a in (c:\Rename.txt) do (
net computer \\%%b /add
Reg Delete "%CCS%Services\Tcpip\Parameters\Hostname" \\%%a
Reg Delete "%CCS%Services\Tcpip\Parameters\NV Hostname" \\%%a
Reg Update "%CCS%Control\%CN%\%CN%\%CN%=%%b" \\%%a
Reg Update "%CCS%Control\%CN%\Active%CN%\%CN%=%%b" \\%%a
Reg Add "%CCS%Services\Tcpip\Parameters\Hostname=%%b" \\%%a
Reg Add "%CCS%Services\Tcpip\Parameters\NV Hostname=%%b" \\%%a
net computer \\%%a /del
)
Thanks,
Clay Calvert
Replace "W" with "L" in email.