how to change a computers name by script

  • Thread starter Thread starter Hein Heinrichsen
  • Start date Start date
Hello
Thank you for your answer but this seems to be only for computers in a
domain, not in workgroups.
any other suggestions?
 
Try something like this...


strcomputer="xxxxxxxxxxxxxxxx"
username="" ' local admin account on computer to be renamed
password=""
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer(strComputer,
"Root\DEFAULT,username,password)
Set objRegistry = objService.Get("StdRegProv")

strKeyPath = "System\CurrentControlSet\Control\ComputerName\ComputerName"
strValueName = "ComputerName"
objRegistry.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,newname.value
strValueName = "ActiveComputerName"
objRegistry.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,newname.value

strKeyPath = "System\CurrentControlSet\Services\Tcpip\Parameters"
strValueName = "HostName"
objRegistry.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,newname.value
strValueName = "NV HostName"
objRegistry.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,newname.value

I've used something similar for a while without any problems.
Pete Forman
 
Back
Top