Back Up a Registry Key with reg export

Export any key subtree to a restorable .reg file in one command — the safe ritual before editing the registry.

WindowsbackupregistrycliLow risk
Run reg export <key> <file.reg> /y to save the subtree, and reg import <file.reg> to restore it.

01Command

Command
$ reg export HKCU\Software\MyApp C:\backup\myapp.reg /y

02What it does

Before scripting reg add changes, exporting the target key gives you an instant rollback: the .reg file contains the full subtree and reg import merges it back. The /y flag silently overwrites an existing backup file, which matters in scheduled backups. Note that reg export saves values but never passwords stored as secret data in encrypted form, and keys with very deep trees export fully — there is no recursion limit to worry about.

03Risk

RiskLow risk
RequirementsExporting HKLM keys requires an elevated prompt

04Undo

Undo
$ reg import C:\backup\myapp.reg

05Sources

  • reg export (Windows Commands)
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents reg export saving a registry key's subtree to a .reg file, including the /y overwrite switch.
  • reg import (Windows Commands)
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents reg import restoring a previously exported .reg file — the natural undo path.

Last verified: 2026-09-17 · Category: Developer