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.
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 /y02What 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
04Undo
Undo
$ reg import C:\backup\myapp.reg05Sources
- reg export (Windows Commands)Evidence: Documents reg export saving a registry key's subtree to a .reg file, including the /y overwrite switch.
- reg import (Windows Commands)Evidence: Documents reg import restoring a previously exported .reg file — the natural undo path.
Last verified: 2026-09-17 · Category: Developer