Computer Hope

Microsoft => Microsoft Windows => Windows XP => Topic started by: turc1616 on August 04, 2008, 01:04:36 PM

Title: Editing the registry in a script
Post 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.
Title: Re: Editing the registry in a script
Post by: Carbon Dudeoxide on August 04, 2008, 10:46:15 PM
Why do you want to do this?
Title: Re: Editing the registry in a script
Post by: turc1616 on August 05, 2008, 06:28:07 AM
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.
Title: Re: Editing the registry in a script
Post by: Sidewinder on August 05, 2008, 08:51:21 AM
The Win32_ComputerSystem class has a rename method which might be helpful:

Code: [Select]
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

Quote
Why do you want to do this?

The paranoia level just reached DEFCON 3 ;D

Title: Re: Editing the registry in a script
Post by: turc1616 on August 05, 2008, 09:06:23 AM
Thanks for the help.  I will give that a try.