Is there a way to prompt the user for new pc name, and change the pc name to
what was input by the user?

Assuming this is going to be done as local admin

Thanks
J

Re: Rename a pc with a script by Marty

Marty
Tue Jan 03 08:10:22 CST 2006


"Jason" <jason@someone.com> wrote in message
news:O$ORfzGEGHA.1736@TK2MSFTNGP14.phx.gbl...
> Is there a way to prompt the user for new pc name, and change the pc name
> to what was input by the user?
>
> Assuming this is going to be done as local admin
>
> Thanks
> J


More info needed, which OS will be on the client, and on the domain
controllers?

Will the PC be a member of a domain or workgroup? The local admin will have
the right to change the computer name, but not the computer account on the
domain controller.




Re: Rename a pc with a script by Jason

Jason
Tue Jan 03 08:46:19 CST 2006

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


"Marty List" <usenet@optimumx.com> wrote in message
news:OVBmw9GEGHA.3004@TK2MSFTNGP15.phx.gbl...
>
> "Jason" <jason@someone.com> wrote in message
> news:O$ORfzGEGHA.1736@TK2MSFTNGP14.phx.gbl...
>> Is there a way to prompt the user for new pc name, and change the pc name
>> to what was input by the user?
>>
>> Assuming this is going to be done as local admin
>>
>> Thanks
>> J
>
>
> More info needed, which OS will be on the client, and on the domain
> controllers?
>
> Will the PC be a member of a domain or workgroup? The local admin will
> have the right to change the computer name, but not the computer account
> on the domain controller.
>
>
>



RE: Rename a pc with a script by ESP

ESP
Tue Jan 03 11:19:01 CST 2006

Watch out for Word-Wrap
ESP

Set oFileSystem = CreateObject("Scripting.FileSystemObject")
Set oWshShell = CreateObject("WScript.Shell")
Set oWshEnvironment = oWshShell.Environment("Process")

'==========================================================================
' Prompt User for new machine name
'==========================================================================
strComputer = InputBox("Enter the new machine name.", "New Machine Name")
If strComputer = "" Then WScript.Quit

'==========================================================================
' Write new machine name to the registry
'==========================================================================
oWshShell.RegWrite
"HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName", strComputer
oWshShell.RegWrite
"HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname",
strComputer

'==========================================================================
' Reboot machine
'==========================================================================
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







"Jason" wrote:

> Is there a way to prompt the user for new pc name, and change the pc name to
> what was input by the user?
>
> Assuming this is going to be done as local admin
>
> Thanks
> J
>
>
>

Re: Rename a pc with a script by Marty

Marty
Tue Jan 03 11:29:07 CST 2006


"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




Re: Rename a pc with a script - Thanks (nm) by Jason

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
>
>
>