Computer Hope
Microsoft => Microsoft Windows => Windows XP => Topic started by: turc1616 on August 04, 2008, 01:04:36 PM
-
I need help trying to figure out how to make a script so i can change a computer's name through a script by the input by the user. I know you have to edit the registry from the command prompt but i am having a hard time figuring out what the syntax needs to be to edit the registry. Thanks for the help.
-
Why do you want to do this?
-
I am working on a test bad for my company and i want to change the computer name to match a serial number if a device for possible failure analysis.
-
The Win32_ComputerSystem class has a rename method which might be helpful:
strComputer="."
newName = InputBox("Enter New Name Of Computer", "Rename Computer")
Set objWMIService=GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers=objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
Err = ObjComputer.Rename(newName)
Next
Why do you want to do this?
The paranoia level just reached DEFCON 3 ;D
-
Thanks for the help. I will give that a try.