Reg export

Discussion of bugs and problems found in Altap Salamander. In your reports, please be as descriptive as possible, and report one incident per report. Do not post crash reports here, send us the generated bug report by email instead, please.
User avatar
SvA
Posts: 483
Joined: 29 Mar 2006, 02:41
Location: DE

Reg export

Post by SvA »

Does anybody know: Is there a way to export several marked keys or values from the Regstry plugin?

In my case I needed several file type associations and their file type definitions e.g.
HKEY_CLASSES_ROOT\.txt
HKEY_CLASSES_ROOT\.doc
HKEY_CLASSES_ROOT\.rtf
HKEY_CLASSES_ROOT\txtfile
HKEY_CLASSES_ROOT\rtffile
Or else, does anybody know a free tool capable of doing this, regardless if it is a gui, command line, or configuration file based one? It should produce standard windows .reg files.
User avatar
tukanos
Posts: 410
Joined: 21 Dec 2005, 19:14

Re: Reg export

Post by tukanos »

SvA wrote: 11 Jan 2022, 20:09 Does anybody know: Is there a way to export several marked keys or values from the Regstry plugin?

In my case I needed several file type associations and their file type definitions e.g.
HKEY_CLASSES_ROOT\.txt
HKEY_CLASSES_ROOT\.doc
HKEY_CLASSES_ROOT\.rtf
HKEY_CLASSES_ROOT\txtfile
HKEY_CLASSES_ROOT\rtffile
Or else, does anybody know a free tool capable of doing this, regardless if it is a gui, command line, or configuration file based one? It should produce standard windows .reg files.
The simplest and safest method is to use MS Windows tools. There is a CLI based too called

Code: Select all

reg export
which exports the key you need.

The exporting from PowerShell (in batch you have to change the ' to ", you could do it without any but I have this habit of surrounding it because it usually prevents issues.):

Code: Select all

reg export 'HKEY_CLASSES_ROOT\.txt' txt_export.reg
The help for the command:

Code: Select all

 reg export /?

REG EXPORT KeyName FileName [/y] [/reg:32 | /reg:64]

  Keyname    ROOTKEY[\SubKey] (local machine only).
    ROOTKEY  [ HKLM | HKCU | HKCR | HKU | HKCC ]
    SubKey   The full name of a registry key under the selected ROOTKEY.

  FileName   The name of the disk file to export.

  /y       Force overwriting the existing file without prompt.

  /reg:32  Specifies the key should be accessed using the 32-bit registry view.

  /reg:64  Specifies the key should be accessed using the 64-bit registry view.

Examples:

  REG EXPORT HKLM\Software\MyCo\MyApp AppBkUp.reg
    Exports all subkeys and values of the key MyApp to the file AppBkUp.reg
User avatar
SvA
Posts: 483
Joined: 29 Mar 2006, 02:41
Location: DE

Re: Reg export

Post by SvA »

Thanks for your reply.

I know about reg.exe. It has the same restriction as Salamander and as Regedit. You can export one key only into a file. You cannot even append more data to a pre-existing file. Rather they all overwrite the file with the new data.

If you need a collection of keys, you will have to merge the files created in several exports in the editor. I am looking for a more direct, less manual way of exporting several keys in one go, or even in multiple commands, but without manual merging.

All tools known to me take one parameter to specify one key and export this key, if it is a data-key, and all contained keys, if the specified key is a folder.

You mentioned PowerShell. This might be a possible solution. I will have to investigate ...
User avatar
tukanos
Posts: 410
Joined: 21 Dec 2005, 19:14

Re: Reg export

Post by tukanos »

SvA wrote: 12 Jan 2022, 16:43 Thanks for your reply.

I know about reg.exe. It has the same restriction as Salamander and as Regedit. You can export one key only into a file. You cannot even append more data to a pre-existing file. Rather they all overwrite the file with the new data.

If you need a collection of keys, you will have to merge the files created in several exports in the editor. I am looking for a more direct, less manual way of exporting several keys in one go, or even in multiple commands, but without manual merging.

All tools known to me take one parameter to specify one key and export this key, if it is a data-key, and all contained keys, if the specified key is a folder.

You mentioned PowerShell. This might be a possible solution. I will have to investigate ...
As sorry, I thought that would be easy for you. You just need to run the script (it does not matter which scripting you use - PowerShell, batch, javascript, vbscript, etc.) in a loop, export the registry into some temporary file names and then merge those files into one file. Everything would be done automagically by the script.
Yes, the first reply by Ansgar Wiechers is the way I would do it. He even nicely got rid of the first line 'Windows Registry Editor Version 5.00' and has it only once the merged file.
Post Reply