Convert hive file into .reg file?

A

Al Dubovick

Many file associations are lost. Need to replace the entire subkey
HKLM\Software\Classes with another previously saved subkey. The replacement
was saved via Save Key from a backed up hive that was previously loaded and
unloaded in regedt32. Although I'm Admin, regedt32 is not giving me
privilege to do Registry > Restore on the Classes subkey with the previously
saved replacement.

Note that Load Hive is unavailable on selected subkeys; you can do it only
at the root of the HKLM tree.

So my workaround idea is to try to convert the extensionless subkey file
(Classes) into a .reg file and then import it. Is there a way to convert a
registry file into registry script file (.reg)? Note that I tried simply
putting a .reg extension on the Classes file, but when I double-click on it
a popup error states that it's not registry script. I've also tried opening
the extensionless Classes file with Notepad via Open With, but the Notepad
window doesn't show registry script.
 
K

Knack

Mark V said:
One thought. Can you load that saved hive file into regedt32 again?
If so, you can then start regedit and see the "loaded hive" (and
export). Close regedit, unload hive, close regedt32.

I do not however know if this helps or not. Never tried what you
need.

There is to my knowledge no way to convert from the binary "Save
key" format to anything else. That format also contains registry
ACLs and can only overwrite/replace (not merge) in any case. If you
cannot "restore" over the existing key, I don't know what else to
recommend. Just to check, you are focusing _on_ the \Classes\ key
and selecting to "Restore..."?

Mark, I thought of that same idea you suggested, but I'm afraid to follow
thru with it all the way until I learn a little bit more about it.

When regedit sees the imported Classes key (loaded by regedt32), of course
that key is in the wrong location; it's adjacent to the root key HKLM
instead of being nested inside HKLM/Software. So my question is when you use
regedit to Export Registry File, does it see the selected key from the
"bottom-up" or from the "top-down". If it exports the key top-down then it
will be incorrect because the key Software will be missing. However, if it
exports bottom-up then it will be perfect, as then it will keep the HKLM key
out of the file.

Knack (Al D.)
 
M

Mark V

In said:
Many file associations are lost. Need to replace the entire subkey
HKLM\Software\Classes with another previously saved subkey. The
replacement was saved via Save Key from a backed up hive that was
previously loaded and unloaded in regedt32. Although I'm Admin,
regedt32 is not giving me privilege to do Registry > Restore on
the Classes subkey with the previously saved replacement.

Note that Load Hive is unavailable on selected subkeys; you can do
it only at the root of the HKLM tree.

So my workaround idea is to try to convert the extensionless
subkey file (Classes) into a .reg file and then import it. Is
there a way to convert a registry file into registry script file
(.reg)? Note that I tried simply putting a .reg extension on the
Classes file, but when I double-click on it a popup error states
that it's not registry script. I've also tried opening the
extensionless Classes file with Notepad via Open With, but the
Notepad window doesn't show registry script.

One thought. Can you load that saved hive file into regedt32 again?
If so, you can then start regedit and see the "loaded hive" (and
export). Close regedit, unload hive, close regedt32.

I do not however know if this helps or not. Never tried what you
need.

There is to my knowledge no way to convert from the binary "Save
key" format to anything else. That format also contains registry
ACLs and can only overwrite/replace (not merge) in any case. If you
cannot "restore" over the existing key, I don't know what else to
recommend. Just to check, you are focusing _on_ the \Classes\ key
and selecting to "Restore..."?
 
M

Mark V

In said:
Mark, I thought of that same idea you suggested, but I'm afraid to
follow thru with it all the way until I learn a little bit more
about it.

When regedit sees the imported Classes key (loaded by regedt32),
of course that key is in the wrong location; it's adjacent to the
root key HKLM instead of being nested inside HKLM/Software. So my
question is when you use regedit to Export Registry File, does it
see the selected key from the "bottom-up" or from the "top-down".
If it exports the key top-down then it will be incorrect because
the key Software will be missing. However, if it exports bottom-up
then it will be perfect, as then it will keep the HKLM key out of
the file.

I am uncertain in any case if you can in fact merge the entire HKLM
\Software\Classes\ into the registry. Never tried. There _could_ be
open handles in some keys that prevent it. I'd ensure a full
registry backup (ntbackup.exe, ERD (With "Also backup..." checked))
in advance for possible use from Recovery Console if things go awry.

You are correct in that the exported (regedit) file, "Classes" will
contain incorrect paths. You would need to load the file in a text
editor and do a search & replace operation to correct that.

For example replacing
HKEY_LOCAL_MACHINE\<somename>\SOFTWARE\Classes
with
HKEY_LOCAL_MACHINE\SOFTWARE\Classes
prior to import.

This regedit export/import is structurally different than "Save
key"/"Restore..." in regedt32.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top