Programming Field

Reg Export - DOS/Command Prompt Reference

[Windows NT series/XP or later] Exports all subkeys and values below the specified registry key to a text-format file. This is one of the operations of Reg command.

* Unlike Reg Save, the execution of this command does not require backup privileges (SeBackupPrivilege).

Syntax

reg[.exe] save <key> <file-name> [/y] [/reg:[32|64]]

Options

<key>

Specifies the key name. For specific instructions on how to specify the key name, please refer to ‘About specifying key names’. However, this command can only operate on keys for the local computer.

The key name is specified with the complete path, and if the key does not exist, an error will occur.

<file-name> Specifies the destination file name for saving the data. Typically, the extension is set to ".reg".
/y Overwrites and saves the file pointed to by <file-name> without displaying a prompt, even if the file already exists. If you omit /y, it prompts you to confirm overwriting when the file exists.
/reg:[32|64]

If there is an environment with both 64-bit and 32-bit versions (WOW64), specifying ‘/reg:32’ will reference registry data used by 32-bit applications (for example, ‘HKLM\Software\WOW6432Node’ for HKLM), and specifying ‘/reg:64’ will reference registry data used by 64-bit applications.

If this option is omitted, the executed Reg.exe will reference the registry corresponding to its bit version. If it is a 64-bit version, it will reference the 64-bit registry; if it is a 32-bit version (located under %SystemRoot%\SysWOW64), it will reference the 32-bit registry. If you want to reference registry data for a specific application and know whether it's 32-bit or 64-bit, you can explicitly specify this option to avoid ambiguity.

* Even if Reg.exe is a 32-bit version, you can reference the 64-bit registry by using ‘/reg:64’.
* If you are using the 64-bit version of Reg.exe, you can also directly specify keys such as ‘HKLM\Software\WOW6432Node’ when referencing the 32-bit registry.

Details

The ‘EXPORT’ command in Reg is used to write registry values and keys to a file in text format. The data exported using this command is in the so-called ‘.reg’ format (registration entries file), which can be used with Reg Import and the ‘Registry Editor’ (Windows 2000? or later) for import purposes.

* Due to the difference in format (hive data) compared to the output from ‘Reg Save’, it cannot be used with ‘Reg Restore’ or ‘Reg Load’.

While the processing content of Reg Export and Reg Save is similar, the data saved by Reg Export is limited to subkeys, values, and value types. It does not include information about the key itself, access permissions, or owner details of the key and subkeys. Therefore, even if you import the data exported by ‘Reg Export’ using ‘Reg Import’, it cannot perform a strict backup or restoration. On the other hand, .reg files are in text format, making them easy to view and edit in applications like Notepad (compared to binary hive data). Therefore, they can be chosen based on ease of handling depending on the situation.

Samples

Sample

reg export "HKCU\Software\My Company\Pure Program" MySettings.reg

Saves the data contained in the ‘HKEY_CURRENT_USER\Software\My Company\Pure Program’ key to the file ‘MySettings.reg’. As an example, this data can be copied and imported onto other computers, serving as ‘customized default values’.

* Attempting to perform an equivalent operation with ‘Reg Save’ may include permissions and owner information in the output data. This could lead to unintended consequences such as failure in ‘Reg Restore’ or creating a key that cannot be manipulated, even if the operation appears successful.