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

Author Topic: script to copy registry key to disk.  (Read 4813 times)

0 Members and 1 Guest are viewing this topic.

mrbishman

    Topic Starter


    Greenhorn

    script to copy registry key to disk.
    « on: September 16, 2010, 10:44:44 AM »
    Is there a way of copying a specific registry key to a drive on a computer (e.g. a usb drive) so that it can later be restored onto a new PC?

    Basically I work with a piece of printing accounting software in my workplace. when the software is installed, it adds a few files to the C: drive, as well as adding a connection string registry key to the system within hkey_local_machine -which provides the credentials for connecting to an sql database (also set up during the installation software).
    I get a lot of calls from customers who decide they want to backup the system and its data and migrate it over to a new server - and i want to create an application that does this, and which would involve the following steps:
    *Stop IIS and Print Spooler services
    *Copy 2 folders from C:\Program Files
    *Copy a specific registry key from tree within hkey_local Machine.

    Once the software has been initially set up on the other server (takes a few minutes with an .exe), I want the application to replace the files on the C: drive with the backed up files - likewise with the single registry key.

    What I'm thinking about is creating the interface in visual basic, and then using scripts to carry out all the procedures, rather than having to do each part manually.
    Is it possible to copy the registry keys using script? If so, do you know what kind it would be? ie.e VBscript, Windows scripting, etc.

    Any advice greatly appreciated.

    Thanks




    Linux711



      Mentor

      Thanked: 59
      • Yes
      • Programming Blog
    • Certifications: List
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: script to copy registry key to disk.
    « Reply #1 on: September 16, 2010, 10:56:03 AM »
    Quote
    Is there a way of copying a specific registry key to a drive on a computer (e.g. a usb drive) so that it can later be restored onto a new PC?

    Yes. Open up regedit. Select the key you want to back up. Press file and then Export (or similar. i am on a mac). Then you can just save it as a .reg file. If this part needs to be done using a script, then you can use REG EXPORT command in batch.

    Then you can just make a batch file and use REG IMPORT [filename].reg and that will add the key back into the registry.

    More information on these commands can be found here:

    http://www.computerhope.com/reg.htm
    YouTube

    "Genius is persistence, not brain power." - Me

    "Insomnia is just a byproduct of, "It can't be done"" - LaVolpe

    mrbishman

      Topic Starter


      Greenhorn

      Re: script to copy registry key to disk.
      « Reply #2 on: September 16, 2010, 11:04:07 AM »
      Is there any way of doing this using a form of programming language / script?
      Ideally I'd like to be able to do this automatically / behind the scenes rather than have to back up the keys, etc manually.

      Linux711



        Mentor

        Thanked: 59
        • Yes
        • Programming Blog
      • Certifications: List
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows 7
      Re: script to copy registry key to disk.
      « Reply #3 on: September 16, 2010, 11:13:25 AM »
      Quote
      If this part needs to be done using a script, then you can use REG EXPORT command in batch.
      YouTube

      "Genius is persistence, not brain power." - Me

      "Insomnia is just a byproduct of, "It can't be done"" - LaVolpe