Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using the Windows cmd command reg:

reg save

Saves a copy of specified subkeys, entries, and values of the registry in a specified file.

reg export

Creates a copy of specified subkeys, entries, and values into a file so that it can be transferred to other servers.

What's the difference between them, except the file being generated as .hiv or .reg?

share|improve this question

migrated from stackoverflow.com Aug 31 '11 at 8:28

This question came from our site for professional and enthusiast programmers.

up vote 7 down vote accepted

The generated file is the difference.

save saves the branch into the Registry's native "hive" format. This preserves key ownership and ACLs, so is best suited for backups and restoring on the same machine.

export exports it into a textual format, suitable for distribution since the .reg format does not preserve any metadata.

share|improve this answer

It's not just that the generated files are different. I noticed that what happens when you use the .reg file vs when you use the .hiv file is quite different

When you import a .reg file, you don't have to specify a path. It writes to your registry based on the .reg file, and leaves new registry keys and entries created between export and import untouched.

Whereas when you import a .hiv file, you have to specify a path. New registry keys and entries created between export and import are deleted.


Here's an example to illustrate.

  1. Create a dummy key with a dummy entry

    reg add hkcu\test
    reg add hkcu\test /v entry /t REG_DWORD /d 1
    
  2. If you run reg query hkcu\test you will see this

    HKEY_CURRENT_USER\test
        (Default) REG_SZ
        entry REG_DWORD 0x1

  3. Export to a .reg file and to a .hiv file

    reg export hkcu\test test.reg
    reg save hkcu\test test.hiv
    
  4. Then create a new entry and a new subkey

    reg add hkcu\test /v new_entry /t REG_SZ /d "ayy lmao"
    reg add hkcu\test\new_key
    
  5. If you run reg query hkcu\test you will see this

    HKEY_CURRENT_USER\test
        (Default) REG_SZ
        entry REG_DWORD 0x1
        new_entry REG_SZ ayy lmao

    HKEY_CURRENT_USER\test\new_key

  6. Import the .reg file we created earlier

    reg import test.reg 
    

    If you run reg query hkcu\test, you will see the same output from #5.

  7. Import the .hiv file we create earlier

    reg restore hkcu\test test.hiv
    

    If you run reg query hkcu\test, you will find that the new items we created in #4 is gone and we get the same output as #2.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.