This post will show you how to load and unload a Registry Hive in Windows 11/10 using the reg load or reg unload commands. You may want to manually load a Registry hive for troubleshooting or scripting; if so, this post will help you.
How to Load a Registry Hive in Windows 11/10
Using Registry Editor
To load a Registry Hive, open REGEDIT and select the Root Key. Only keys that allow hive loading and they are:
- HKEY_LOCAL_MACHINE or
- HKEY_USERS
Click on File and then on Load Hive.
Next, browse to the hive file location which is C:\Windows\System32\config.
Select SYSTEM, SOFTWARE, SAM or the desired hive file.
Finally, enter a temporary name for the loaded hive and edit it as required.
Using Command line
Open a Command Prompt window, and execute the following command:
reg load HKLM\TempHiveName C:\Backup\SYSTEM.hiv
Here, replace the following:
- HKLM\TempHiveName with the temporary key name under HKEY_LOCAL_MACHINE.
- C:\Backup\SYSTEM.hiv with the actual path to the hive file.
For working in recovery environments, you can use this method.
How to Unload a Registry Hive in Windows 11/10
To unload a registry hive in Windows that you loaded, you can use the Registry Editor or the reg unload command. Here’s how to do it safely and effectively
Using REGEDIT
To load a Registry Hive, open Registry Editor and select the Key and then click on File and then on Load Hive.
Using Command Prompt
Open a Command Prompt as administrator, and execute the following command:
reg unload HKLM\TempHiveName
Here, replace HKLM\TempHiveName with the temporary key name under HKEY_LOCAL_MACHINE. The common root keys are HKLM, HKCU, HKU, HKCR, and HKCC.
Ensure that there are no open handles and execute the command.
This method is best when working in recovery environments.
Unload a Registry Hive Access denied error message
If you encounter an ‘Access denied’ message when unloading a Registry Hive, you must close any open handles.
If the hive was accessed in PowerShell or a script, execute this command in an elevated PowerShell window:
$result = New-Item -Path "Registry::HKLM\TempHiveName\TheKeyName" $result.Handle.Close() [gc]::Collect() [gc]::WaitForPendingFinalizers()
If you get an “Access Denied” error, make sure no apps or scripts are still referencing the hive. You may also have to wait for garbage collection to release handles.
Unloading a hive removes it from memory, preventing lingering changes.
How to load an offline Windows Registry Hive?
To load an offline Windows Registry Hive, open Registry Editor and select “Load Hive” from the File menu. Choose the registry hive file, typically located in the Windows\System32\Config directory. Enter a key name to access the data. Make changes as needed and then unload the hive when finished to save changes.