Sign-in / Sign-up
Your question

How to change hostname in windows xp by command line

Tags:
  • Hostname
  • Command Line
  • Computers
  • Windows XP
  • Windows 7
Last response: in Windows 7
January 31, 2012 10:03:43 AM

how to change computer name using command line in windows?

More about : change hostname windows command line

January 31, 2012 10:10:56 AM

Do you have to use a command line?
m
0
l
a b $ Windows 7
January 31, 2012 2:24:35 PM

Copy into notepad and save with .vbs extension, run in command prompt as admin.

strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2″)

Name = "MY_PC_NAME"
Set colComputers = objWMIService.ExecQuery (“Select * from Win32_ComputerSystem”)

For Each objComputer in colComputers
err = objComputer.Rename(name)
if err <> 0 then
wscript.echo “There was an error renaming the machine. Please restart, and try again.”
else
wscript.echo “Machine successfully renamed: ” & Name
end if
Next
m
0
l