Is it possible to change the hostname in Windows 2003 from the command line with out-of-the-box tools?
I don't know of a command to do this, but you could do it in VBScript or something similar. Somthing like:
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"
The netdom.exe command line program can be used. This is available from the Windows XP Support Tools or Server 2003 Support Tools (both on the installation CD).
Usage guidelines here
The netdom.exe command will do that. See http://shurl.us/ra/. You will have to install the Support Tools.
wmic computersystem set Name=BlahComputer
I think 'Name' is the property you need. This WMIC should be built into XP/2K3 and above. Can't run it on my desktop, but I've practised with 'description' property. i.e. wmic computersystem set Desciprion="Preets Computer"
I do believe that you need to reboot,
Don't see a link to reply to the reply above (maybe noscipt blocking it), but here is my small improvement to the wmi command above:
> wmic computersystem where name="%COMPUTERNAME%" call rename name="NEW"