WINDOWS INSTALLER ERROR
Error 1402 and 1406: Could Not Open Key or Write Value
The setup needed to open a registry key, or write a value in it, and could not. The message names the key and a system error number, so the problem is tied to that one key.
WHAT WINDOWS SAYS
Could not open key: [2]. System error [3].
Message 1406 is "Could not write value [2] to key [3]. System error [4]." Office setups word them as "Error 1402: Setup cannot open Registry Key" and "Error 1406: Setup cannot write the value to the registry key", with 1401 for a key that cannot be created. The numbers in brackets are fields for the registry key and a system error number; in Windows' error list, 5 is Access is denied.
Wording from Microsoft's documentation, linked under Sources.
TECHNICAL SUMMARY
| Number | 1402, 1406, 1401 |
|---|---|
| Where it appears | Message shown by a setup |
| In PC Tweaker Uninstaller | Shows the exit code |
What causes Error 1402 and 1406
- The permissions on the registry subkey named in the message. Microsoft's first method is to set the permission of the Everyone group to Full Control on the subkeys listed in the error message.
- A third-party application is denying access to the registry subkey. Microsoft's article names a security program as the example and says that in a clean boot it can no longer deny access.
How to fix Error 1402 and 1406, safest step first
Microsoft's article, written for Office 2003 to 2010 setups, gives three methods for the registry key. We list its permission change last because the other two change nothing permanent; each step says how to go back.
Make a restore point before the steps that change something
Select Start, type Create a restore point, open it, and on the System Protection tab choose Create. Microsoft notes that System Protection is not turned on by default; if Create is greyed out, choose Configure and turn it on for the system drive first.
To undo: A restore point changes nothing by itself. To go back later, run System Restore and pick it: Microsoft says it reverts system files, the registry and installed programs, and leaves your personal files alone.
Shut down the third-party application that is denying access, then choose Retry
Microsoft's second method: disable the third-party application, select Retry in the setup's error box, and re-enable the application when the setup has completed and the computer has restarted.
To undo: Start the application again. Do not leave protection off longer than the setup takes.
Try again in a clean boot
A clean boot starts Windows with only Microsoft services and no startup programs, so another program cannot interfere. Follow Microsoft's clean boot article, then run the setup or removal again.
To undo: Microsoft's article ends with the steps to reset the computer to start normally: turn the services and startup items back on, then restart.
Change the permissions of the key named in the message
Microsoft's first method: set the permission of the Everyone group to Full Control on the registry subkeys listed in the error message. In Registry Editor, go to that key, right-click it > Permissions. Before changing anything, export the key and write down the current entries.
To undo: Set the entries back as you noted them. The restore point from the first step restores the registry as a whole.
Check it yourself, without changing anything
Find the message in the Application log (PowerShell)
Microsoft documents that errors from the installer's Error table are logged with an event ID equal to the error number plus 10,000. Nothing is changed.
PowerShellGet-WinEvent -FilterHashtable @{ LogName='Application'; ProviderName='MsiInstaller'; Id=11402,11406 } -MaxEvents 5 | Format-List TimeCreated, MessageRead who has access to that key (PowerShell)
Replace the path after Registry:: with the key from your message. It lists the accounts and their rights and changes nothing.
PowerShell(Get-Acl 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Example\Key').Access | Format-Table IdentityReference, RegistryRights, AccessControlType
What PC Tweaker Uninstaller does with Error 1402 and 1406
Shows the exit codePC Tweaker Uninstaller removes a Windows Installer program with the command it shows you first in the Removal Brief, msiexec.exe /x {ProductCode} /qn /norestart, after asking Windows for a restore point when the removal needs administrator rights. Because that run is silent, no message box with this number appears: the report shows the exit code msiexec.exe returned and says the program may not be fully removed, and the attempt is kept in the Removal Ledger with that code. The Uninstaller does not change registry permissions and does not switch other programs off. Its registry cleanup (Pro) is for keys a removed program left behind, each saved as a .reg file first; it is not a way around a key that cannot be opened.
PC Tweaker Uninstaller: see the exact command before a removal runs
Common questions
What does "System error 5" in the message mean?
In Windows' list of system error codes, 5 is ERROR_ACCESS_DENIED: Access is denied. The message puts that number next to the registry key it could not open or write.
Do error 1402 and 1406 only affect Office?
No. They are in Microsoft's list of Windows Installer messages, which any setup package can show. Microsoft's step-by-step article is written for Office 2003 to 2010.
Is it safe to give Everyone full control of a registry key?
It is Microsoft's first method for the keys named in the error. Export the key and note its permissions first so you can put them back, and try the two methods that change nothing permanent before it.