Cannot import .REG file; Not all data was successfully written to registry

Sometimes, when applying the registry settings using a .reg file, you may get one of the following errors:

Cannot import file.reg: Not all data was successfully written to the registry. Some keys are open by the system or other processes, or you have insufficient privileges to perform this operation.

cannot import .reg file - error accessing registry

Cannot import file.reg: Error accessing the registry.

cannot import .reg file - error accessing registry

Registry files (or registration entries) are files that are used to deploy registry settings quickly to other computers. The registration entries have a file extension .reg that can be run by double-clicking or using the reg.exe command line. You can also manually import .reg files from the Registry Editor window.

Cause

The above errors are caused if the user account that’s running the .reg file doesn’t have the necessary write permissions for the registry keys mentioned inside the file. It could be possible that you’re trying to modify a system-wide setting while logged in as a Limited user. If you’re logged in as administrator and still the error is seen, read below:

  • The first error “Not all data was successfully written to the registry” denotes that the system was able to access the registry key, but unable to create or write to the specified registry values.
  • The other error “Error accessing the registry” occurs when the system is not able to create or access the registry branch specified in the .reg file.

Either way, these errors are caused by missing write permissions for the specified registry keys.

When an error is encountered during the registry import process, Windows would skip to the next line and execute the rest of the instructions in the .reg file, without abruptly stopping the merge/import process. Let’s say, the .reg file is configured to write to two different registry locations. If it’s unable to write to the 1st location, it skips to the next line and attempts to run the rest of the commands.

Fix: Error “Not all data was successfully written to the registry”

To prevent the “Error accessing the registry”, “Not all data was successfully written to the registry” or similar errors from occurring, reapply the registry file from an administrator account.

If the problem persists, from an administrator account, launch the Registry Editor (regedit.exe) assign the necessary (write) permissions for the registry keys you’re trying to modify.

Registry Editor - Permissions... context menu option
Registry Editor – Permissions… context menu option

Check out these articles to know how to fix the permissions for a specific registry key:

But, for which registry key should I modify the permissions? Read below for the answer.

How do you find out which entry in a .reg file is causing the problem?

Sample Scenario: Let’s say you have a .reg file that has instructions to modify values in different registry branches. Here’s an example:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.Png\DefaultIcon]
"oldicon"="%SystemRoot%\System32\imageres.dll,-71"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.Tiff\DefaultIcon]
@="d:\icons\icons.dll,5"
"oldicon"="%SystemRoot%\System32\imageres.dll,-122"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.Bitmap\DefaultIcon]
"oldicon"="%SystemRoot%\System32\imageres.dll,-70"

When you run that .reg file, you may get the following error:

Cannot import file.reg: Not all data was successfully written to the registry. Some keys are open by the system or other processes, or you have insufficient privileges to perform this operation.

(Once an error is encountered, Windows skips to the next line and carries out the rest of the instructions in the file.)

Narrowing down the registry key

To know which registry key is causing the problem, track down the ACCESS DENIED event(s) using the Process Monitor utility from Microsoft. Process Monitor tracks registry and file system accesses in real-time and logs the result for each event.



For more information, check out the following articles:

Note: If the Registry Editor (which runs the .reg file type by default) knows that certain registry keys can’t be written to, it doesn’t attempt to modify those registry values. However, it carries out the registry key (not value) creation operation if the .reg file has instructions to create a new key. In case the operation fails, it would encounter the ACCESS DENIED error.Whereas the reg.exe command-line tool would right away create the key or write to every key/value mentioned in the .reg file. So, the reg.exe tool would be ideal for us to track the ACCESS DENIED events.

So, with Process Monitor tracking mode On, open a Command Prompt (admin) window and use the following command-line syntax to import a .reg file:

reg.exe  import  filename_with_path.reg

cannot import .reg file - error accessing registry

If Process Monitor is currently in tracking mode, it shows the ACCESS DENIED entries exactly.

cannot import .reg file - error accessing registry

The error occurs because the PhotoViewer.FileAssoc.Tiff branch is owned by the TrustedInstaller account and your account doesn’t have write access to it.

cannot import .reg file - error accessing registry

(Likewise, in a production environment, you may have a locked-down Policies registry key. In that case, attempting to write to a subkey under Policies would cause the error “Error accessing the registry”)

Now, all you need to do is launch the Registry Editor and fix the permissions for those registry keys. This resolves the “Cannot import filename.reg. Not all data was successfully written to the registry.” error.


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded Winhelponline.com in 2005.

Leave a Comment