Programming Field

Reg Save - DOS/Command Prompt Reference

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

* The execution of the command requires backup privileges (SeBackupPrivilege). If you are running the command from the Command Prompt and it doesn't have ‘Administrator’ in the window title, you may need to open Command Prompt with elevation, such as by selecting ‘Run as Administrator’.

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’.

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.
/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 ‘SAVE’ command in Reg is used to export values and keys from the registry to a file. The data saved here can be used with Reg Restore and Reg Load.

* The data saved is referred to as hive data and serves as the storage format for registry data managed by the system, such as ‘NTUSER.DAT’. It is not in the form of text data used in .reg files.

Reg Export and Reg Save have similar processing, but with Reg Save, the saved data includes not only subkeys and values but also information about the key itself, as well as access permissions and ownership of subkeys. Since these pieces of information are also applied during Restore or Load, it's essential to be mindful of whether the permissions will be accessible at the destination when performing backup, restoration, and loading across computers.

Samples

Sample

reg save "\\AkoPC\HKLM\Software\My Company" Backup\ako\MyCompany_Key.dat

Saves the data of the ‘HKEY_LOCAL_MACHINE\Software\My Company’ key on the computer ‘ako’ to the file ‘Backup\ako\MyCompany_Key.dat’.