Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Editing the registry in a script  (Read 2426 times)

0 Members and 1 Guest are viewing this topic.

turc1616

    Topic Starter


    Greenhorn

    Editing the registry in a script
    « 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.

    Carbon Dudeoxide

    • Global Moderator

    • Mastermind
    • Thanked: 169
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Experience: Guru
    • OS: Mac OS
    Re: Editing the registry in a script
    « Reply #1 on: August 04, 2008, 10:46:15 PM »
    Why do you want to do this?

    turc1616

      Topic Starter


      Greenhorn

      Re: Editing the registry in a script
      « Reply #2 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.

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Editing the registry in a script
      « Reply #3 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

      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      turc1616

        Topic Starter


        Greenhorn

        Re: Editing the registry in a script
        « Reply #4 on: August 05, 2008, 09:06:23 AM »
        Thanks for the help.  I will give that a try.