I fixed this bug by simplifying the installer script to use SHELL_CONTEXT as the registry hive, instead of checking the UserType and then executing the same logic on a HKCU or HKLM depending on its value. Using SHELL_CONTEXT does exactly the same thing in less than half the code.