Jason
Tue Jan 03 13:34:29 CST 2006
"Marty List" <usenet@optimumx.com> wrote in message
news:uMnj0sIEGHA.2704@TK2MSFTNGP15.phx.gbl...
>
> "Jason" <jason@someone.com> wrote in message
> news:%23JLY2RHEGHA.2036@TK2MSFTNGP14.phx.gbl...
>> Marty
>>
>> The pc is not on the domain. I've got two XP machines that need basic IP
>> communication, but they are sharing the same name. The user is a local
>> admin account.
>> I can intruct the user how to do it via system properties, computer name
>> but a dialog would be a bit easier.
>>
>> Thanks
>
>
> Jason,
>
> Here is a script based on this example in the TechNet Script Center:
>
http://www.microsoft.com/technet/scriptcenter/scripts/ad/computer/cptrvb14.mspx
>
> '============================
> Option Explicit
>
> Dim objWMIService, colComputers, objComputer
> Dim NewName, Result
>
> NewName = InputBox("Enter a new name for this computer:","Rename
> Computer")
>
> NewName = Trim(NewName)
> If NewName = "" Then WScript.Quit(10)
>
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!root\cimv2")
>
> Set colComputers = objWMIService.ExecQuery _
> ("SELECT * FROM Win32_ComputerSystem")
>
> For Each objComputer in colComputers
> WScript.Echo "Renaming " & objComputer.Name & " to " & NewName
> Result = objComputer.Rename(NewName)
> If Result = 0 Then
> WScript.Echo "Successful."
>
> ' You may want to reboot the system here.
> Else
> WScript.Echo "Failed, error " & Result & "."
> End If
> Next
>
>
> WScript.Quit(Result)
> '============================
>
>
> More info:
>
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/rename_method_in_class_win32_computersystem.asp
>
>
>