Rename PC w/o using the wizard

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any way to make a script to rename a PC w/o having to manually do
it thru the properties of My Computer?
 
Is there any way to make a script to rename a PC w/o having to manually do
it thru the properties of My Computer?

Use the rename method for Win32_ComputerSystem WMI class

example: (from http://msdn.microsoft.com/library/d...name_method_in_class_win32_computersystem.asp)

Name = "name"
Password = "password"
Username = "username"

Set objWMIService = GetObject("Winmgmts:root\cimv2")

' Call always gets only one Win32_ComputerSystem object.
For Each objComputer in
objWMIService.InstancesOf("Win32_ComputerSystem")

Return = objComputer.rename(Name,Password,User)
If Return <> 0 Then
WScript.Echo "Rename failed. Error = " & Err.Number
Else
WScript.Echo "Rename succeeded. Reboot for new name to go into
effect"
End If

Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top