Fix it now
The installer tried to touch a registry key and the operating system refused. All five codes in this family print the key path and a system error number, and those two values are the whole diagnosis: the path tells you where to work and the number tells you what was refused. It is an ACL problem on one branch, not a damaged package.
msiexec /i "C:\path\to\package.msi" /l*v %USERPROFILE%\Desktop\msi.log
reg export "HKLM\SOFTWARE\Vendor" %USERPROFILE%\Desktop\vendor-backup.reg
- Open the log and find the error number. The message reads like “Could not write value X to key Y. System error 5.” Note both the full key and the system error.
- Start
regeditas administrator and go to the parent of the key named in the message. - Right-click it, choose Permissions, then Advanced. Set the owner to Administrators and tick the option to replace the owner on subcontainers and objects.
- Close and reopen the Advanced dialog, give Administrators and SYSTEM full control, tick the option to replace all child object permission entries with inheritable entries from this object, and apply.
- Run the installer again from the elevated prompt.
Work on the smallest branch that contains the failing key. A sweeping change from the root of SOFTWARE downwards takes a long time and flattens restrictions other products rely on.
If the install now completes you are done. If the same key locks again, or the path is under HKEY_CURRENT_USER, the next section explains which case you have.
Why it happens
The per-machine half of a Windows Installer transaction runs as SYSTEM, and SYSTEM normally has full control over the machine hives. A registry write failing is therefore a sign that something has changed the access control list on that branch: a hardening baseline, a security template delivered by Group Policy, an uninstaller from another product, or a profile that was deleted while its security identifier was still on the key.
The five codes differ only in the operation that was refused, and Microsoft publishes each of them with the key path and a system error number embedded. 1402 is a key that could not be opened. 1404 is a key that could not be deleted. 1406 is a value that could not be written. 1403 is a value that could not be deleted, and 1405 one that could not be read. The remedy is the same in every case, so treat them as one problem with five labels.
The system error in the message is the part most readers skip and the part that saves the most time. 5 is access denied, which is the ACL case this article is mostly about. 2 and 3 are file or path not found, which usually means the parent key is missing rather than protected. 1009 and 1015 are published as a corrupt registry database and a corrupted registry, which is a different problem with a different fix. 1018 is narrower still: an illegal operation on a key that has been marked for deletion.
The branch has non-default permissions
You have this one if The key exists in regedit, the system error is 5, and Administrators or SYSTEM are missing from its permission list or hold only partial rights.
- Open regedit elevated and go to the parent key named in the message.
- Take ownership with Administrators, replacing the owner on subcontainers and objects.
- Reopen the Advanced dialog so the new ownership takes effect, then grant Administrators and SYSTEM full control.
- Replace all child object permission entries with inheritable entries from this object, apply, and rerun the installer.
Orphaned account identifiers are stuck in the ACL
You have this one if The permission list shows entries as raw S-1-5-21 strings instead of readable names.
- Open the Advanced permissions dialog on the parent key.
- Remove the unresolved entries. They belong to accounts that no longer exist and cannot be evaluated.
- Confirm Administrators, SYSTEM and, where appropriate, Users still hold their normal entries.
- Replace child permissions, apply, and retry.
Group Policy keeps reapplying a restrictive template
You have this one if The fix works, the install succeeds, and the same key is locked down again within hours or after a reboot.
- Run
gpresult /h %USERPROFILE%\Desktop\gpresult.htmland read the Security Settings section, specifically Registry. - If a registry security policy is setting the ACL, the change has to be made in the policy rather than on the machine.
- For a one-off install on a managed device, ask for the setting to be scoped away from it, install, and let policy return.
A local ACL change on a machine covered by a registry security policy is temporary by design. Policy wins at the next refresh, every time.
The failing path is under HKEY_CURRENT_USER
You have this one if The key in the message begins HKEY_CURRENT_USER, and the install is being run by a deployment agent, a scheduled task or a service rather than by the person sitting at the machine.
- Decide whether the package should be per-machine. If it should, deploy it so the writes go to the machine hive, using whatever property the package exposes for that.
- If it genuinely needs per-user registration, run it in the user’s own session rather than as SYSTEM.
- For a manual test, open an elevated prompt inside the affected user’s session rather than switching to another account.
Full reference
The message text behind each number
| Number | Published message |
|---|---|
| 1402 | Could not open key: [2]. System error [3]. |
| 1403 | Could not delete value [2] from key [3]. System error [4]. |
| 1404 | Could not delete key [2]. System error [3]. |
| 1405 | Could not read value [2] from key [3]. System error [4]. |
| 1406 | Could not write value [2] to key [3]. System error [4]. |
1405 is the odd one and worth calling out. If the installer only needed to read and was refused, the key exists and denies read access, which is a much narrower fault than a write being blocked. It usually means somebody removed the Users entry from a branch that other software still reads.
Telling the variants apart from the path alone
| What the path shows | What it indicates |
|---|---|
Begins HKEY_LOCAL_MACHINE\SOFTWARE\Classes |
COM or file-association registration; that branch has non-default ACLs |
Begins HKEY_CURRENT_USER |
The install is running in a context whose hive is not writable, or is not the user you think |
| Contains a long S-1-5-21 string | An orphaned account identifier is still present in the ACL |
Contains WOW6432Node |
A 32-bit component on 64-bit Windows; check that view of the branch, not the 64-bit one |
| The same key breaks again after you fix it | A security template is being reapplied at policy refresh |
Commands that are safe to run first
| Command | Purpose |
|---|---|
reg export "HKLM\SOFTWARE\Vendor" backup.reg |
Backs up a branch before you change it |
reg query "HKLM\SOFTWARE\Vendor" /s |
Dumps a branch so you can see what is actually there |
msiexec /i package.msi /l*v log.txt |
Produces the log that names the failing key in full |
gpresult /h report.html |
Shows which policies, including security templates, apply to the machine |
Export before you edit, every time. A wrong permission change on a machine hive is one of the few registry mistakes that can leave a system that will not start cleanly, and a .reg file costs nothing to produce.
When the key named does not exist
This is common and confuses people. If the message names a key that is not there, the installer was trying to create it and was refused on the parent. Work on the nearest ancestor that does exist and make sure inheritance flows down from it. The same applies when the path runs several levels deeper than anything present: fix the deepest existing ancestor, then let the installer create the rest.
Before you reach for a whole-registry permission reset
- A blanket reset undoes deliberate hardening across the machine and can break unrelated software. Fixing the single branch in the message is safer and is almost always sufficient.
- If several unrelated branches are refusing SYSTEM, suspect a security template rather than accidental damage, and go and read it.
- Compare the ACL with a clean build of the same Windows version. Registry permissions are per-machine state, so the difference is usually obvious once you have something to compare against.
- If the hive itself is damaged – system errors 1009 or 1015 rather than 5 – permissions are not your problem and repairing or restoring the hive is.
- Take a system restore point or a full backup before any recursive change, not after.
Every code this article covers
| Code | What it points at | Source |
|---|---|---|
1402 |
A registry key could not be opened; the message carries the key and a system error number | Microsoft Learn |
1404 |
A registry key could not be deleted | Microsoft Learn |
1406 |
A value could not be written to the named key | Microsoft Learn |
1403 |
A value could not be deleted from the named key | Microsoft Learn |
1405 |
A value could not be read from the named key, so the key exists and denies read access | Microsoft Learn |
Confirm the fix worked
- Rerun the installer and confirm it completes without rolling back.
- Open the previously failing key in regedit and confirm Administrators and SYSTEM both show full control.
- Confirm the permission entries are marked as inherited, so a future child key gets them automatically.
- Launch the application and use the feature that depends on the registration, such as opening an associated file type.
- Reboot, then check the key once more. If the permissions have reverted, a policy is putting them back and the fix belongs there.
Questions people ask about this
Do I need to buy anything to resolve this?
No. This is a permissions repair on a machine you already own. No product key, edition upgrade or paid utility changes the outcome, and any tool that offers to sell you a fix for 1402 is charging for a registry permission change you can make yourself.
Should I use a tool that resets permissions across the whole registry?
Only as a last resort, and take a full backup first. Blanket resets undo deliberate hardening and can break other applications. The key named in the message is the only place that needs work.
The error names a key that does not exist. What then?
The installer was trying to create it and was refused on the parent. Work on the nearest existing ancestor key and make sure inheritance flows down from it.
What is the system error number in the message for?
It tells you what was refused. 5 is access denied, which is the permissions case. 2 and 3 are path or file not found, usually a missing parent key. 1009 is published as a corrupt configuration registry database and 1015 as a corrupted registry, and both need repair rather than an ACL change. 1018 means the key has been marked for deletion, which usually points at an earlier action in the same transaction.
Why does the same package install fine on another machine?
Because the damage is local. Registry permissions are per-machine state, so a clean build has the defaults and a machine with history does not. Comparing the two ACLs is the fastest way to see exactly what is missing.
