Works on a stand alone system.
Not tested on a domainmember

'==========================================================================
'
' VBScript Source File
'
' NAME: RenameComputer.vbs
'
' AUTHOR: Paessens Daniel , Hewlett-Packard Company
' DATE : 3/28/2007
'
' COMMENT: This script will change the computername
'
'==========================================================================
Option Explicit
Dim oWshShell 'Windows Script Host Shell object
Set oWshShell = CreateObject("WScript.Shell")
sNewName = "New Name"
'Rename computer
oWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName", sNewName
oWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname", sNewName
'Restart computer
Dim OpSysSet, OpSys
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each OpSys In OpSysSet
OpSys.Reboot()
Next
WScript.Quit
