Vbscript / Operating System / Rename Computer
Rename a computer. This should be done before joining a domain.
strDomain = "domainname" strPassword = "password" strUser = "username"
strNewComputerName = "newName"
Set objNetwork = CreateObject("WScript.Network") strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\" & strComputer & "\root\cimv2:Win32_ComputerSystem.Name=" & strComputer & "") ErrCode = objComputer.Rename(strNewComputerName, strPassword, strUser) If ErrCode = 0 Then MsgBox "Computer renamed correctly." Else MsgBox "Eror changing computer name. Error code: " & ErrCode End If
Please note that a disclaimer applies to any code on this page.
|