I have created this script to rename a remote computer, but am having
problems getting it to work.
It always fails with an error code of 5.


strComputerRmt = InputBox("Enter the Remote machine name.", "Remote Machine
Name")
strComputerNew = InputBox("Enter the new machine name.", "New Machine Name")

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputerRmt & "\root\CIMV2")

Set colComputers = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem","WQL",_
wbemFlagReturnImmediately + wbemFlagForwardOnly)

' Rename machine
For Each objComputer in colComputers
Result = objComputer.Rename(strComputerNew)
If Result = 0 Then
WScript.Echo "Successful."

' Reboot machine
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}\\" & strComputerRmt &
"\root\cimv2").ExecQuery("select * from Win32_OperatingSystem where
Primary=true")
For Each OpSys In OpSysSet
OpSys.Reboot()
Next

Else
WScript.Echo "Failed, error " & Result & "."
End If
Next
WScript.Sleep 5000
WScript.Quit


Any advice will be greatly appreciated.